Sha256: 8d1f82680926c2651bb96e165f8d601594ed41cc78201ef08392dfc88b94dd2c

Contents?: true

Size: 587 Bytes

Versions: 31

Compression:

Stored size: 587 Bytes

Contents

module StateMachine
  module Model

    def self.included(klass)
      klass.extend ClassMethods
    end

    module ClassMethods

      def register_transitions(service_hash)
        service_hash.each do |service_name, service_class|
          define_method("#{service_name}") {
            service_class.new(self)
          }
          define_method("#{service_class.target_state}?") {
            service_class.target_state.to_s == self.send(service_class.status_field)
          }
          delegate service_class.action_name, to: service_name
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
pulitzer-0.15.31 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.30 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.29 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.28 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.27 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.26 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.25 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.24 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.23 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.22 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.21 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.20 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.19 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.18 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.17 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.16 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.15 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.14 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.13 spec/dummy/lib/state_machine/model.rb
pulitzer-0.15.12 spec/dummy/lib/state_machine/model.rb