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