Class: Brujula::TypeExtender::Method
- Inherits:
-
Object
- Object
- Brujula::TypeExtender::Method
- Defined in:
- lib/brujula/type_extender/method.rb
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
Instance Method Summary collapse
- #apply_inherit_chain ⇒ Object
- #call ⇒ Object
- #extended_object ⇒ Object
-
#initialize(definition:) ⇒ Method
constructor
A new instance of Method.
Constructor Details
#initialize(definition:) ⇒ Method
Returns a new instance of Method.
6 7 8 |
# File 'lib/brujula/type_extender/method.rb', line 6 def initialize(definition:) @definition = definition end |
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
4 5 6 |
# File 'lib/brujula/type_extender/method.rb', line 4 def definition @definition end |
Instance Method Details
#apply_inherit_chain ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/brujula/type_extender/method.rb', line 20 def apply_inherit_chain definition.is.inject(definition.dup) do |object, trait| Brujula::Mergers::ObjectMerger.new( superinstance: trait, instance: object ).call end end |
#call ⇒ Object
10 11 12 13 14 |
# File 'lib/brujula/type_extender/method.rb', line 10 def call return definition if definition.is.nil? extended_object end |
#extended_object ⇒ Object
16 17 18 |
# File 'lib/brujula/type_extender/method.rb', line 16 def extended_object @extended_object ||= apply_inherit_chain end |