module StateManager::Adapters::Base::ClassMethods
Public Instance Methods
adapter_name()
click to toggle source
The name of the adapter
# File lib/state_manager/adapters/base.rb, line 7 def adapter_name @adapter_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
available?()
click to toggle source
Whether this adapter is available for the current library. This is only true if the ORM that the adapter is for is currently defined.
# File lib/state_manager/adapters/base.rb, line 20 def available? matching_ancestors.any? && Object.const_defined?(matching_ancestors[0].split('::')[0]) end
matches?(klass)
click to toggle source
Whether the adapter should be used for the given class.
# File lib/state_manager/adapters/base.rb, line 30 def matches?(klass) matches_ancestors?(klass.ancestors.map {|ancestor| ancestor.name}) end
matches_ancestors?(ancestors)
click to toggle source
Whether the adapter should be used for the given list of ancestors.
# File lib/state_manager/adapters/base.rb, line 35 def matches_ancestors?(ancestors) (ancestors & matching_ancestors).any? end
matching_ancestors()
click to toggle source
The list of ancestor names that cause this adapter to matched.
# File lib/state_manager/adapters/base.rb, line 25 def matching_ancestors [] end