Class: Action::State
- Inherits:
-
Object
- Object
- Action::State
- Extended by:
- ClassMethods
- Includes:
- Wisper::Publisher
- Defined in:
- lib/action/state.rb,
lib/action/state/class_methods.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #create_action ⇒ Object
-
#initialize(options = {}) ⇒ State
constructor
A new instance of State.
- #to_h ⇒ Object
- #to_json(*options) ⇒ Object
Methods included from ClassMethods
Constructor Details
#initialize(options = {}) ⇒ State
Returns a new instance of State.
11 12 13 14 15 16 17 |
# File 'lib/action/state.rb', line 11 def initialize = {} = .symbolize_keys @action_class = [:action_class] @action_class = @action_class.constantize if String === @action_class @config = .fetch(:config, ActiveSupport::OrderedHash.new) @status = .fetch(:status, :initial).to_sym end |
Instance Attribute Details
#status ⇒ Object
Returns the value of attribute status.
9 10 11 |
# File 'lib/action/state.rb', line 9 def status @status end |
Instance Method Details
#==(other) ⇒ Object
38 39 40 |
# File 'lib/action/state.rb', line 38 def == other self.class == other.class && self.to_h == other.to_h end |
#create_action ⇒ Object
19 20 21 22 23 24 |
# File 'lib/action/state.rb', line 19 def create_action @action_class.new.configure do |config| config.replace(@config) config.freeze end end |
#to_h ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/action/state.rb', line 30 def to_h { action_class: @action_class.name, config: @config, status: @status, } end |
#to_json(*options) ⇒ Object
26 27 28 |
# File 'lib/action/state.rb', line 26 def to_json * to_h.to_json(*) end |