Method: ObjectState::State#to_hash
- Defined in:
- lib/object_state/state.rb
#to_hash(attrs = {}) ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/object_state/state.rb', line 82 def to_hash(attrs = {}) return unless model.present? key = model.respond_to?(:model_name) ? model.model_name.singular : model.class.to_s.underscore value = super() value = value.merge(id: model.id) if model.respond_to?(:id) value = value.merge(attrs) { key => value } end |