Class: Riddler::Step
- Inherits:
-
Object
- Object
- Riddler::Step
- Includes:
- Includeable
- Defined in:
- lib/riddler/step.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#preview_enabled ⇒ Object
readonly
Returns the value of attribute preview_enabled.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(definition, context) ⇒ Step
constructor
A new instance of Step.
- #to_hash ⇒ Object
Methods included from Includeable
Constructor Details
#initialize(definition, context) ⇒ Step
Returns a new instance of Step.
23 24 25 26 |
# File 'lib/riddler/step.rb', line 23 def initialize definition, context @definition = definition @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
5 6 7 |
# File 'lib/riddler/step.rb', line 5 def context @context end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
5 6 7 |
# File 'lib/riddler/step.rb', line 5 def definition @definition end |
#preview_enabled ⇒ Object (readonly)
Returns the value of attribute preview_enabled.
5 6 7 |
# File 'lib/riddler/step.rb', line 5 def preview_enabled @preview_enabled end |
Class Method Details
.for(definition, context) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/riddler/step.rb', line 15 def self.for definition, context step_type = definition["type"] klass = subclasses.detect { |k| k.type == step_type } klass.new definition, context end |
.inherited(subclass) ⇒ Object
11 12 13 |
# File 'lib/riddler/step.rb', line 11 def self.inherited subclass self.subclasses << subclass end |
.subclasses ⇒ Object
7 8 9 |
# File 'lib/riddler/step.rb', line 7 def self.subclasses @@subclasses ||= [] end |
Instance Method Details
#to_hash ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/riddler/step.rb', line 28 def to_hash { content_type: "step", type: self.class.type, id: definition["id"], name: definition["name"] } end |