Module: ActiveFedora::AttributeMethods::Write

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_fedora/attribute_methods/write.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

WriterMethodCache =
Class.new(AttributeMethodCache) do
                      private

  def method_body(method_name, const_name)
    "    def \#{method_name}(value)\n      name = ::ActiveFedora::AttributeMethods::AttrNames::ATTR_\#{const_name}\n      write_attribute(name, value)\n    end\n    EOMETHOD\n  end\nend.new\n"

Instance Method Summary collapse

Instance Method Details

#write_attribute(attribute_name, value) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/active_fedora/attribute_methods/write.rb', line 23

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