Sha256: e8d1b9065c62274976dc1e972fb5af2443866fbab53ef46c4722ffadc7359d4a
Contents?: true
Size: 807 Bytes
Versions: 5
Compression:
Stored size: 807 Bytes
Contents
module RightnowOms module ActsAsCartable def acts_as_cartable? false end def acts_as_cartable(opts = { name: :name, price: :price }) cartable_config.update(opts) if opts.is_a? Hash class_eval do include RightnowOms::ActsAsCartable::InstanceMethods extend RightnowOms::ActsAsCartable::ClassMethods end end def cartable_config @cartable_config ||= { name: :name, price: :price } end module ClassMethods def acts_as_cartable? self.included_modules.include?(InstanceMethods) end end module InstanceMethods def cartable_name self.send(self.class.cartable_config[:name]) end def cartable_price self.send(self.class.cartable_config[:price]) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems