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.
27 28 29 30 31 32 33 34 |
# File 'app/models/spree/setup_tasks.rb', line 27 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.
25 26 27 |
# File 'app/models/spree/setup_tasks.rb', line 25 def key @key end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
25 26 27 |
# File 'app/models/spree/setup_tasks.rb', line 25 def position @position end |
Instance Method Details
#available?(subject) ⇒ Boolean
Returns whether the task applies to this subject at all.
44 45 46 |
# File 'app/models/spree/setup_tasks.rb', line 44 def available?(subject) @if.nil? || !!@if.call(subject) end |
#done?(subject) ⇒ Boolean
Returns whether the task is complete.
38 39 40 |
# File 'app/models/spree/setup_tasks.rb', line 38 def done?(subject) !!@done.call(subject) end |