Module: Familia::DataType::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#has_relations?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/familia/data_type.rb', line 63

def has_relations?
  @has_relations ||= false
end

#inherited(obj) ⇒ Object



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

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



40
41
42
43
# File 'lib/familia/data_type.rb', line 40

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)



34
35
36
37
38
# File 'lib/familia/data_type.rb', line 34

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

#uri(val = nil) ⇒ Object



45
46
47
48
# File 'lib/familia/data_type.rb', line 45

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

#valid_keys_only(opts) ⇒ Object



59
60
61
# File 'lib/familia/data_type.rb', line 59

def valid_keys_only(opts)
  opts.select { |k, _| DataType.valid_options.include? k }
end