Class: Sortah::Component
- Inherits:
-
Object
- Object
- Sortah::Component
- Defined in:
- lib/sortah/util/component.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #defined?(context) ⇒ Boolean
-
#initialize(name, opts = {}, *potential_block) ⇒ Component
constructor
A new instance of Component.
- #run_dependencies!(email, context) ⇒ Object
Constructor Details
#initialize(name, opts = {}, *potential_block) ⇒ Component
Returns a new instance of Component.
5 6 7 8 9 |
# File 'lib/sortah/util/component.rb', line 5 def initialize(name, opts = {}, *potential_block) @name = name @opts = opts @block = potential_block.first unless potential_block.empty? end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
3 4 5 |
# File 'lib/sortah/util/component.rb', line 3 def block @block end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/sortah/util/component.rb', line 3 def name @name end |
Instance Method Details
#defined?(context) ⇒ Boolean
15 16 17 |
# File 'lib/sortah/util/component.rb', line 15 def defined?(context) !!context[name] end |
#run_dependencies!(email, context) ⇒ Object
11 12 13 |
# File 'lib/sortah/util/component.rb', line 11 def run_dependencies!(email, context) dependencies(context).each { |lens| lens.run!(email, context) } end |