Sha256: 49d6735f69577bf5c49bfeb05a7411b86f941ce07d07f683f25306dfc3d5cdc7
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
module StateMachines module Integrations # Provides a set of base helpers for managing individual integrations module Base module ClassMethods # The default options to use for state machines using this integration attr_reader :defaults # The name of the integration def integration_name @integration_name ||= begin name = self.name.split('::').last name.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2') name.gsub!(/([a-z\d])([A-Z])/, '\1_\2') name.downcase! name.to_sym end end # The list of ancestor names that cause this integration to matched. def matching_ancestors [] end # Whether the integration should be used for the given class. def matches?(klass) matching_ancestors.any? { |ancestor| klass <= ancestor } end # Whether the integration should be used for the given list of ancestors. def matches_ancestors?(ancestors) (ancestors & matching_ancestors).any? end end def self.included(base) #:nodoc: base.extend ClassMethods end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
state_machines-0.6.0 | lib/state_machines/integrations/base.rb |
state_machines-0.5.0 | lib/state_machines/integrations/base.rb |