Class: Axel::Associations::Base
- Inherits:
-
Object
- Object
- Axel::Associations::Base
- Defined in:
- app/models/axel/associations/base.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
-
#options ⇒ Object
Returns the value of attribute options.
-
#relation_name ⇒ Object
Returns the value of attribute relation_name.
Instance Method Summary collapse
- #handles_method?(method_name) ⇒ Boolean
-
#initialize(model, relation_name, options) ⇒ Base
constructor
A new instance of Base.
- #run_method(instance, method_name, *args, &block) ⇒ Object
Constructor Details
#initialize(model, relation_name, options) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 |
# File 'app/models/axel/associations/base.rb', line 8 def initialize(model, relation_name, ) self.model = model self.relation_name = relation_name.to_s self. = || {} end |
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
4 5 6 |
# File 'app/models/axel/associations/base.rb', line 4 def model @model end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'app/models/axel/associations/base.rb', line 6 def @options end |
#relation_name ⇒ Object
Returns the value of attribute relation_name.
5 6 7 |
# File 'app/models/axel/associations/base.rb', line 5 def relation_name @relation_name end |
Instance Method Details
#handles_method?(method_name) ⇒ Boolean
14 15 16 |
# File 'app/models/axel/associations/base.rb', line 14 def handles_method?(method_name) matchers.any? { |matcher| method_name.to_s.match(matcher) } end |
#run_method(instance, method_name, *args, &block) ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/models/axel/associations/base.rb', line 18 def run_method(instance, method_name, *args, &block) if included? included_getter(instance, *args, &block) else method_chooser(method_name)[instance, *args, &block] end end |