Module: Familia::DataType::ClassMethods
- Included in:
- Familia::DataType
- Defined in:
- lib/familia/data_type/class_methods.rb
Overview
ClassMethods - Class-level DSL methods for defining DataType behavior
This module is extended into classes that inherit from Familia::DataType, providing class methods for type registration, configuration, and inheritance.
Key features:
- Type registration system for creating DataType subclasses
- Database and connection configuration
- Inheritance hooks for propagating settings
- Option validation and filtering
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
38 39 40 41 |
# File 'lib/familia/data_type/class_methods.rb', line 38 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.
19 20 21 |
# File 'lib/familia/data_type/class_methods.rb', line 19 def parent @parent end |
#prefix ⇒ Object
Returns the value of attribute prefix.
19 20 21 |
# File 'lib/familia/data_type/class_methods.rb', line 19 def prefix @prefix end |
#suffix ⇒ Object
Returns the value of attribute suffix.
19 20 21 |
# File 'lib/familia/data_type/class_methods.rb', line 19 def suffix @suffix end |
#uri(val = nil) ⇒ Object
Returns the value of attribute uri.
19 20 21 |
# File 'lib/familia/data_type/class_methods.rb', line 19 def uri @uri end |
Instance Method Details
#inherited(obj) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/familia/data_type/class_methods.rb', line 48 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)
25 26 27 28 29 |
# File 'lib/familia/data_type/class_methods.rb', line 25 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
34 35 36 |
# File 'lib/familia/data_type/class_methods.rb', line 34 def registered_type(methname) @registered_types[methname] end |
#relations? ⇒ Boolean
60 61 62 |
# File 'lib/familia/data_type/class_methods.rb', line 60 def relations? @has_related_fields ||= false end |
#valid_keys_only(opts) ⇒ Object
56 57 58 |
# File 'lib/familia/data_type/class_methods.rb', line 56 def valid_keys_only(opts) opts.slice(*DataType.) end |