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) {
  private

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

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