class Action::State
Attributes
status[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/action/state.rb, line 11 def initialize options = {} options = options.symbolize_keys @action_class = options[:action_class] @action_class = @action_class.constantize if String === @action_class @config = options.fetch(:config, ActiveSupport::OrderedHash.new) @status = options.fetch(:status, :initial).to_sym end
Public Instance Methods
==(other)
click to toggle source
# File lib/action/state.rb, line 38 def == other self.class == other.class && self.to_h == other.to_h end
create_action()
click to toggle source
# File lib/action/state.rb, line 19 def create_action @action_class.new.configure do |config| config.replace(@config) config.freeze end end
status=(new_status)
click to toggle source
# File lib/action/state.rb, line 42 def status= new_status old_status = @status @status = new_status broadcast :status_changed, self, new_status, old_status @status end
to_h()
click to toggle source
# File lib/action/state.rb, line 30 def to_h { action_class: @action_class.name, config: @config, status: @status, } end
to_json(*options)
click to toggle source
# File lib/action/state.rb, line 26 def to_json *options to_h.to_json(*options) end