Sha256: 6f2c4764b129fb0f156668548dca566b14bac3aee917982566637ba791a8c58b
Contents?: true
Size: 552 Bytes
Versions: 1
Compression:
Stored size: 552 Bytes
Contents
# frozen_string_literal: true module HasStates module Stateable extend ActiveSupport::Concern included do has_many :states, class_name: 'HasStates::Base', as: :stateable, dependent: :destroy end # Instance methods for managing states def add_state(type, status: 'pending', metadata: {}, state_class: HasStates::State) states.create!( type: state_class.name, state_type: type, status: status, metadata: metadata ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stateful_models-0.0.2 | lib/has_states/stateable.rb |