Class: Interactify::Dsl::IfInteractor
- Inherits:
-
Object
- Object
- Interactify::Dsl::IfInteractor
- Defined in:
- lib/interactify/dsl/if_interactor.rb
Instance Attribute Summary collapse
-
#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) ⇒ 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) ⇒ IfInteractor
Returns a new instance of IfInteractor.
16 17 18 19 20 21 |
# File 'lib/interactify/dsl/if_interactor.rb', line 16 def initialize(evaluating_receiver, condition, succcess_arg, failure_arg) @evaluating_receiver = evaluating_receiver @condition = condition @success_arg = succcess_arg @failure_arg = failure_arg end |
Instance Attribute Details
#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) ⇒ 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) ifable = new(evaluating_receiver, condition, succcess_interactor, failure_interactor) ifable.attach_klass end |
Instance Method Details
#attach_klass ⇒ Object
46 47 48 49 50 |
# File 'lib/interactify/dsl/if_interactor.rb', line 46 def attach_klass name = if_klass_name namespace.const_set(name, klass) namespace.const_get(name) end |
#failure_interactor ⇒ Object
27 28 29 |
# File 'lib/interactify/dsl/if_interactor.rb', line 27 def failure_interactor @failure_interactor ||= build_chain(@failure_arg, false) end |
#if_klass_name ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/interactify/dsl/if_interactor.rb', line 56 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
34 35 36 |
# File 'lib/interactify/dsl/if_interactor.rb', line 34 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
40 41 42 43 44 |
# File 'lib/interactify/dsl/if_interactor.rb', line 40 def klass_basis @klass_basis ||= Class.new do include Interactify end end |
#namespace ⇒ Object
52 53 54 |
# File 'lib/interactify/dsl/if_interactor.rb', line 52 def namespace evaluating_receiver end |
#success_interactor ⇒ Object
23 24 25 |
# File 'lib/interactify/dsl/if_interactor.rb', line 23 def success_interactor @success_interactor ||= build_chain(@success_arg, true) end |