Class: Interactify::Wiring::CallableRepresentation
- Inherits:
-
Object
- Object
- Interactify::Wiring::CallableRepresentation
- Defined in:
- lib/interactify/wiring/callable_representation.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#wiring ⇒ Object
readonly
Returns the value of attribute wiring.
Instance Method Summary collapse
- #all_keys ⇒ Object
- #assign_previously_defined(error_context:) ⇒ Object
- #expected_keys ⇒ Object
-
#initialize(filename:, klass:, wiring:) ⇒ CallableRepresentation
constructor
A new instance of CallableRepresentation.
- #inspect ⇒ Object
- #organizer? ⇒ Boolean
- #promised_keys ⇒ Object
- #validate_callable(error_context: ErrorContext.new) ⇒ Object
- #validate_children(error_context:) ⇒ Object
Constructor Details
#initialize(filename:, klass:, wiring:) ⇒ CallableRepresentation
Returns a new instance of CallableRepresentation.
12 13 14 15 16 |
# File 'lib/interactify/wiring/callable_representation.rb', line 12 def initialize(filename:, klass:, wiring:) @filename = filename @klass = klass @wiring = wiring end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
8 9 10 |
# File 'lib/interactify/wiring/callable_representation.rb', line 8 def filename @filename end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
8 9 10 |
# File 'lib/interactify/wiring/callable_representation.rb', line 8 def klass @klass end |
#wiring ⇒ Object (readonly)
Returns the value of attribute wiring.
8 9 10 |
# File 'lib/interactify/wiring/callable_representation.rb', line 8 def wiring @wiring end |
Instance Method Details
#all_keys ⇒ Object
35 36 37 |
# File 'lib/interactify/wiring/callable_representation.rb', line 35 def all_keys expected_keys.concat(promised_keys) end |
#assign_previously_defined(error_context:) ⇒ Object
47 48 49 50 51 |
# File 'lib/interactify/wiring/callable_representation.rb', line 47 def assign_previously_defined(error_context:) return unless contract? error_context.append_previously_defined_keys(all_keys) end |
#expected_keys ⇒ Object
27 28 29 |
# File 'lib/interactify/wiring/callable_representation.rb', line 27 def expected_keys klass.respond_to?(:expected_keys) ? Array(klass.expected_keys) : [] end |
#inspect ⇒ Object
39 40 41 |
# File 'lib/interactify/wiring/callable_representation.rb', line 39 def inspect "#<#{self.class.name}#{object_id} @filename=#{filename}, @klass=#{klass.name}>" end |
#organizer? ⇒ Boolean
43 44 45 |
# File 'lib/interactify/wiring/callable_representation.rb', line 43 def organizer? klass.respond_to?(:organized) && klass.organized.any? end |
#promised_keys ⇒ Object
31 32 33 |
# File 'lib/interactify/wiring/callable_representation.rb', line 31 def promised_keys klass.respond_to?(:promised_keys) ? Array(klass.promised_keys) : [] end |
#validate_callable(error_context: ErrorContext.new) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/interactify/wiring/callable_representation.rb', line 18 def validate_callable(error_context: ErrorContext.new) if organizer? assign_previously_defined(error_context:) validate_children(error_context:) end validate_self(error_context:) end |
#validate_children(error_context:) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/interactify/wiring/callable_representation.rb', line 53 def validate_children(error_context:) klass.organized.each do |interactor| interactor_as_callable = interactor_lookup[interactor] next if interactor_as_callable.nil? error_context = interactor_as_callable.validate_callable(error_context:) end error_context end |