Module: Familia::DataType::ClassMethods

Included in:
Familia::DataType
Defined in:
lib/familia/data_type.rb

Overview

DataType::ClassMethods

Instance Method Summary collapse

Instance Method Details

#inherited(obj) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/familia/data_type.rb', line 52

def inherited(obj)
  Familia.trace :DATATYPE, nil, "#{obj} is my kinda type", caller(1..1) if Familia.debug?
  obj.logical_database = logical_database
  obj.default_expiration = default_expiration # method added via Features::Expiration
  obj.uri = uri
  obj.parent = self
  super
end

#logical_database(val = nil) ⇒ Object



42
43
44
45
# File 'lib/familia/data_type.rb', line 42

def logical_database(val = nil)
  @logical_database = val unless val.nil?
  @logical_database || parent&.logical_database
end

#register(klass, methname) ⇒ Object

To be called inside every class that inherits DataType +methname+ is the term used for the class and instance methods that are created for the given +klass+ (e.g. set, list, etc)



36
37
38
39
40
# File 'lib/familia/data_type.rb', line 36

def register(klass, methname)
  Familia.trace :REGISTER, nil, "[#{self}] Registering #{klass} as #{methname.inspect}", caller(1..1) if Familia.debug?

  @registered_types[methname] = klass
end

#relations?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/familia/data_type.rb', line 65

def relations?
  @has_relations ||= false # rubocop:disable ThreadSafety/ClassInstanceVariable
end

#uri(val = nil) ⇒ Object



47
48
49
50
# File 'lib/familia/data_type.rb', line 47

def uri(val = nil)
  @uri = val unless val.nil?
  @uri || (parent ? parent.uri : Familia.uri)
end

#valid_keys_only(opts) ⇒ Object



61
62
63
# File 'lib/familia/data_type.rb', line 61

def valid_keys_only(opts)
  opts.slice(*DataType.valid_options)
end