Class: Brujula::TypeExtender::ResourceType
- Inherits:
-
Object
- Object
- Brujula::TypeExtender::ResourceType
- Defined in:
- lib/brujula/type_extender/resource_type.rb
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
Instance Method Summary collapse
- #call ⇒ Object
- #extended_object ⇒ Object
-
#initialize(definition:) ⇒ ResourceType
constructor
A new instance of ResourceType.
- #parent_definition ⇒ Object
- #within_root_resource_types? ⇒ Boolean
Constructor Details
#initialize(definition:) ⇒ ResourceType
Returns a new instance of ResourceType.
6 7 8 |
# File 'lib/brujula/type_extender/resource_type.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/resource_type.rb', line 4 def definition @definition end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 |
# File 'lib/brujula/type_extender/resource_type.rb', line 10 def call return definition if definition.type.nil? extended_object end |
#extended_object ⇒ Object
24 25 26 27 28 |
# File 'lib/brujula/type_extender/resource_type.rb', line 24 def extended_object @extended_object ||= Brujula::Mergers::ObjectMerger.new( superinstance: parent_definition, instance: definition ).call end |
#parent_definition ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/brujula/type_extender/resource_type.rb', line 16 def parent_definition if within_root_resource_types? # maybe its not preload definition.parent.fetch(definition.type) else definition.root.resource_types.fetch(definition.type) end end |