Sha256: ce327602919880f1999477e3c08aa4e13d6fcc31f9b3d2f63829b56c0afbfbc6
Contents?: true
Size: 771 Bytes
Versions: 6
Compression:
Stored size: 771 Bytes
Contents
module Soulless module Attributes module ClassMethods def attribute(name, type = nil, options = {}) super(name, type, options) if super define_attribute_methods(name) define_reader(name) define_writer(name) end def define_reader(attribute) define_method(attribute.to_sym) do attribute_set[attribute.to_sym].get(self) end end def define_writer(attribute) define_method("#{attribute}=".to_sym) do |value| send("#{attribute}_will_change!") unless value == attribute_set[attribute.to_sym].get(self) super(value) end end end def self.prepended(base) class << base prepend ClassMethods end end end end
Version data entries
6 entries across 6 versions & 1 rubygems