Module: Familia::Base::ClassMethods
- Defined in:
- lib/familia/base.rb
Instance Attribute Summary collapse
-
#dump_method ⇒ Object
Returns the value of attribute dump_method.
-
#feature_definitions ⇒ Object
readonly
Returns the value of attribute feature_definitions.
-
#features_available ⇒ Object
readonly
Returns the value of attribute features_available.
-
#load_method ⇒ Object
Returns the value of attribute load_method.
Instance Method Summary collapse
-
#add_feature(klass, feature_name, depends_on: []) ⇒ Object
-
#find_feature(feature_name) ⇒ Object
Find a feature by name, traversing this class’s ancestry chain.
Instance Attribute Details
#dump_method ⇒ Object
Returns the value of attribute dump_method.
29 30 31 |
# File 'lib/familia/base.rb', line 29 def dump_method @dump_method end |
#feature_definitions ⇒ Object (readonly)
Returns the value of attribute feature_definitions.
28 29 30 |
# File 'lib/familia/base.rb', line 28 def feature_definitions @feature_definitions end |
#features_available ⇒ Object (readonly)
Returns the value of attribute features_available.
28 29 30 |
# File 'lib/familia/base.rb', line 28 def features_available @features_available end |
#load_method ⇒ Object
Returns the value of attribute load_method.
29 30 31 |
# File 'lib/familia/base.rb', line 29 def load_method @load_method end |
Instance Method Details
#add_feature(klass, feature_name, depends_on: []) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/familia/base.rb', line 31 def add_feature(klass, feature_name, depends_on: []) @features_available ||= {} Familia.trace :ADD_FEATURE, klass, feature_name, caller(1..1) if Familia.debug? # Create field definition object feature_def = FeatureDefinition.new( name: feature_name, depends_on: depends_on, ) # Track field definitions after defining field methods @feature_definitions ||= {} @feature_definitions[feature_name] = feature_def features_available[feature_name] = klass end |
#find_feature(feature_name) ⇒ Object
Find a feature by name, traversing this class’s ancestry chain
49 50 51 |
# File 'lib/familia/base.rb', line 49 def find_feature(feature_name) Familia::Base.find_feature(feature_name, self) end |