module ObjectState::Owner::ClassMethods
Public Instance Methods
object_state(options = {}, &block)
click to toggle source
Calls superclass method
# File lib/object_state/owner.rb, line 12 def object_state(options = {}, &block) cls = self class_name = options.fetch(:class_name, nil) @object_state_class ||= class_name ? class_name.constantize : Class.new(ObjectState::State) @object_state_class.class_eval do setup_attributes cls, &block end if instance_methods.include?(:cache_key) && options.fetch(:merge_cache_key, true) define_method :cache_key do |*args| return super(*args) unless object_state [super(*args), object_state.cache_key].reject(&:blank?).join('/') end end end
object_state_class()
click to toggle source
# File lib/object_state/owner.rb, line 8 def object_state_class @object_state_class ||= Class.new(ObjectState::State) end