Class: Spree::SetupTasks::Definition
- Inherits:
-
Object
- Object
- Spree::SetupTasks::Definition
- Defined in:
- app/models/spree/setup_tasks.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
Instance Method Summary collapse
-
#available?(subject) ⇒ Boolean
Whether the task applies to this subject at all.
-
#done?(subject) ⇒ Boolean
Whether the task is complete.
-
#initialize(key, position:, done:, **options) ⇒ Definition
constructor
A new instance of Definition.
Constructor Details
#initialize(key, position:, done:, **options) ⇒ Definition
Returns a new instance of Definition.
24 25 26 27 28 29 30 31 |
# File 'app/models/spree/setup_tasks.rb', line 24 def initialize(key, position:, done:, **) raise ArgumentError, "done: must respond to #call" unless done.respond_to?(:call) @key = key.to_sym @position = position @done = done @if = [:if] end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
22 23 24 |
# File 'app/models/spree/setup_tasks.rb', line 22 def key @key end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
22 23 24 |
# File 'app/models/spree/setup_tasks.rb', line 22 def position @position end |
Instance Method Details
#available?(subject) ⇒ Boolean
Returns whether the task applies to this subject at all.
41 42 43 |
# File 'app/models/spree/setup_tasks.rb', line 41 def available?(subject) @if.nil? || !!@if.call(subject) end |
#done?(subject) ⇒ Boolean
Returns whether the task is complete.
35 36 37 |
# File 'app/models/spree/setup_tasks.rb', line 35 def done?(subject) !!@done.call(subject) end |