Class: Interactify::Dsl::IfInteractor
- Inherits:
-
Object
- Object
- Interactify::Dsl::IfInteractor
- Defined in:
- lib/interactify/dsl/if_interactor.rb
Instance Attribute Summary collapse
-
#caller_info ⇒ Object
readonly
Returns the value of attribute caller_info.
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
-
#evaluating_receiver ⇒ Object
readonly
Returns the value of attribute evaluating_receiver.
Class Method Summary collapse
Instance Method Summary collapse
- #attach_klass ⇒ Object
- #failure_interactor ⇒ Object
- #if_klass_name ⇒ Object
-
#initialize(evaluating_receiver, condition, succcess_arg, failure_arg, caller_info:) ⇒ IfInteractor
constructor
A new instance of IfInteractor.
-
#klass ⇒ Object
allows us to dynamically create an interactor chain that iterates over the packages and uses the passed in each_loop_klasses.
-
#klass_basis ⇒ Object
so we have something to attach subclasses to during building of the outer class, before we finalize the outer If class.
- #namespace ⇒ Object
- #success_interactor ⇒ Object
Constructor Details
#initialize(evaluating_receiver, condition, succcess_arg, failure_arg, caller_info:) ⇒ IfInteractor
Returns a new instance of IfInteractor.
16 17 18 19 20 21 22 |
# File 'lib/interactify/dsl/if_interactor.rb', line 16 def initialize(evaluating_receiver, condition, succcess_arg, failure_arg, caller_info:) @evaluating_receiver = evaluating_receiver @condition = condition @success_arg = succcess_arg @failure_arg = failure_arg @caller_info = caller_info end |
Instance Attribute Details
#caller_info ⇒ Object (readonly)
Returns the value of attribute caller_info.
9 10 11 |
# File 'lib/interactify/dsl/if_interactor.rb', line 9 def caller_info @caller_info end |
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
9 10 11 |
# File 'lib/interactify/dsl/if_interactor.rb', line 9 def condition @condition end |
#evaluating_receiver ⇒ Object (readonly)
Returns the value of attribute evaluating_receiver.
9 10 11 |
# File 'lib/interactify/dsl/if_interactor.rb', line 9 def evaluating_receiver @evaluating_receiver end |
Class Method Details
.attach_klass(evaluating_receiver, condition, succcess_interactor, failure_interactor, caller_info:) ⇒ Object
11 12 13 14 |
# File 'lib/interactify/dsl/if_interactor.rb', line 11 def self.attach_klass(evaluating_receiver, condition, succcess_interactor, failure_interactor, caller_info:) ifable = new(evaluating_receiver, condition, succcess_interactor, failure_interactor, caller_info:) ifable.attach_klass end |
Instance Method Details
#attach_klass ⇒ Object
47 48 49 50 51 |
# File 'lib/interactify/dsl/if_interactor.rb', line 47 def attach_klass name = if_klass_name namespace.const_set(name, klass) namespace.const_get(name) end |
#failure_interactor ⇒ Object
28 29 30 |
# File 'lib/interactify/dsl/if_interactor.rb', line 28 def failure_interactor @failure_interactor ||= build_chain(@failure_arg, false) end |
#if_klass_name ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/interactify/dsl/if_interactor.rb', line 57 def if_klass_name @if_klass_name ||= begin prefix = condition.is_a?(Proc) ? "Proc" : condition prefix = "If#{prefix.to_s.camelize}" UniqueKlassName.for(namespace, prefix) end end |
#klass ⇒ Object
allows us to dynamically create an interactor chain that iterates over the packages and uses the passed in each_loop_klasses
35 36 37 |
# File 'lib/interactify/dsl/if_interactor.rb', line 35 def klass IfKlass.new(self).klass end |
#klass_basis ⇒ Object
so we have something to attach subclasses to during building of the outer class, before we finalize the outer If class
41 42 43 44 45 |
# File 'lib/interactify/dsl/if_interactor.rb', line 41 def klass_basis @klass_basis ||= Class.new do include Interactify end end |
#namespace ⇒ Object
53 54 55 |
# File 'lib/interactify/dsl/if_interactor.rb', line 53 def namespace evaluating_receiver end |
#success_interactor ⇒ Object
24 25 26 |
# File 'lib/interactify/dsl/if_interactor.rb', line 24 def success_interactor @success_interactor ||= build_chain(@success_arg, true) end |