Module: Familia::DataType::ClassMethods
- Included in:
- Familia::DataType
- Defined in:
- lib/familia/data_type.rb
Overview
DataType::ClassMethods
Instance Attribute Summary collapse
- #logical_database(val = nil) ⇒ Object
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#suffix ⇒ Object
Returns the value of attribute suffix.
-
#uri(val = nil) ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #inherited(obj) ⇒ Object
-
#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).
-
#registered_type(methname) ⇒ Object
Get the registered type class from a given method name +methname+ is the method name used to register the class (e.g. :set, :list, etc) Returns the registered class or nil if not found.
- #relations? ⇒ Boolean
- #valid_keys_only(opts) ⇒ Object
Instance Attribute Details
#logical_database(val = nil) ⇒ Object
54 55 56 57 |
# File 'lib/familia/data_type.rb', line 54 def logical_database(val = nil) @logical_database = val unless val.nil? @logical_database || parent&.logical_database end |
#parent ⇒ Object
Returns the value of attribute parent.
35 36 37 |
# File 'lib/familia/data_type.rb', line 35 def parent @parent end |
#prefix ⇒ Object
Returns the value of attribute prefix.
35 36 37 |
# File 'lib/familia/data_type.rb', line 35 def prefix @prefix end |
#suffix ⇒ Object
Returns the value of attribute suffix.
35 36 37 |
# File 'lib/familia/data_type.rb', line 35 def suffix @suffix end |
#uri(val = nil) ⇒ Object
Returns the value of attribute uri.
35 36 37 |
# File 'lib/familia/data_type.rb', line 35 def uri @uri end |
Instance Method Details
#inherited(obj) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/familia/data_type.rb', line 64 def inherited(obj) Familia.trace :DATATYPE, nil, "#{obj} is my kinda type" if Familia.debug? obj.logical_database = logical_database obj.default_expiration = default_expiration # method added via Features::Expiration obj.uri = uri super 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)
41 42 43 44 45 |
# File 'lib/familia/data_type.rb', line 41 def register(klass, methname) Familia.trace :REGISTER, nil, "[#{self}] Registering #{klass} as #{methname.inspect}" if Familia.debug? @registered_types[methname] = klass end |
#registered_type(methname) ⇒ Object
Get the registered type class from a given method name +methname+ is the method name used to register the class (e.g. :set, :list, etc) Returns the registered class or nil if not found
50 51 52 |
# File 'lib/familia/data_type.rb', line 50 def registered_type(methname) @registered_types[methname] end |
#relations? ⇒ Boolean
76 77 78 |
# File 'lib/familia/data_type.rb', line 76 def relations? @has_related_fields ||= false end |
#valid_keys_only(opts) ⇒ Object
72 73 74 |
# File 'lib/familia/data_type.rb', line 72 def valid_keys_only(opts) opts.slice(*DataType.) end |