Sha256: 27b7e0bf4fc539ce83f6698f05e45b31a23f6c90c4b4254b9950d80c025b0c12
Contents?: true
Size: 1.24 KB
Versions: 11
Compression:
Stored size: 1.24 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) matches_ancestors?(klass.ancestors.map { |ancestor| ancestor.name }) end # Whether the integration should be used for the given list of ancestors. def matches_ancestors?(ancestors) (ancestors & matching_ancestors).any? end end extend ClassMethods def self.included(base) #:nodoc: base.class_eval { extend ClassMethods } end end end end
Version data entries
11 entries across 11 versions & 2 rubygems