Sha256: ed9bcd0020a65516e19c8667330b3d0b7e2c8a365b290e05dc580f070b152ab0
Contents?: true
Size: 1.18 KB
Versions: 33
Compression:
Stored size: 1.18 KB
Contents
module ActiveFedora module AttributeMethods module Write WriterMethodCache = Class.new(AttributeMethodCache) { private def method_body(method_name, const_name) <<-EOMETHOD def #{method_name}(value) name = ::ActiveFedora::AttributeMethods::AttrNames::ATTR_#{const_name} write_attribute(name, value) end EOMETHOD end }.new extend ActiveSupport::Concern included do attribute_method_suffix "=" end def write_attribute(attribute_name, value) if self.class.properties.key?(attribute_name) @attributes[attribute_name] = value else raise ActiveModel::MissingAttributeError, "can't write unknown attribute `#{attribute_name}'" end end private def attribute=(attribute_name, value) write_attribute(attribute_name, value) end module ClassMethods def define_method_attribute=(name) method = WriterMethodCache[name.to_s] generated_attribute_methods.module_eval { define_method "#{name}=", method } end end end end end
Version data entries
33 entries across 33 versions & 1 rubygems