Sha256: b31079dfd2b2f94d05f39a774a11da3adb5e69921e91db4e7001491f8302a254
Contents?: true
Size: 1.54 KB
Versions: 6
Compression:
Stored size: 1.54 KB
Contents
module ActiveData module Model module Attributes module Reflections class Attribute < Base def self.build(target, generated_methods, name, *args, &block) attribute = super(target, generated_methods, name, *args, &block) generate_methods name, generated_methods attribute end def self.generate_methods(name, target) target.class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{name} attribute('#{name}').read end def #{name}= value attribute('#{name}').write(value) end def #{name}? attribute('#{name}').query end def #{name}_before_type_cast attribute('#{name}').read_before_type_cast end def #{name}_came_from_user? attribute('#{name}').came_from_user? end def #{name}_default attribute('#{name}').default end def #{name}_values attribute('#{name}').enum.to_a end RUBY end def defaultizer @defaultizer ||= options[:default] end def enumerizer @enumerizer ||= options[:enum] || options[:in] end def normalizers @normalizers ||= Array.wrap(options[:normalize] || options[:normalizer] || options[:normalizers]) end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems