Sha256: 56d4278133c463d6b5281fae86c78a629769010e0576f7ffeed3771f7fb55e90

Contents?: true

Size: 1.27 KB

Versions: 53

Compression:

Stored size: 1.27 KB

Contents

module ActiveFedora
  module AttributeMethods
    module Write
      module ClassMethods
        protected

          def define_method_attribute=(name)
            name = name.to_s
            safe_name = name.unpack('h*'.freeze).first
            ActiveFedora::AttributeMethods::AttrNames.set_name_cache safe_name, name

            generated_attribute_methods.module_eval <<-STR, __FILE__, __LINE__ + 1
              def __temp__#{safe_name}=(value)
                name = ::ActiveRecord::AttributeMethods::AttrNames::ATTR_#{safe_name}
                write_attribute(name, value)
              end
              alias_method #{(name + '=').inspect}, :__temp__#{safe_name}=
              undef_method :__temp__#{safe_name}=
            STR
          end
      end

      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
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
active-fedora-11.5.6 lib/active_fedora/attribute_methods/write.rb
active-fedora-11.2.1 lib/active_fedora/attribute_methods/write.rb
active-fedora-12.0.3 lib/active_fedora/attribute_methods/write.rb
active-fedora-11.5.5 lib/active_fedora/attribute_methods/write.rb
active-fedora-11.5.4 lib/active_fedora/attribute_methods/write.rb
active-fedora-11.5.3 lib/active_fedora/attribute_methods/write.rb
active-fedora-12.0.2 lib/active_fedora/attribute_methods/write.rb
active-fedora-12.0.1 lib/active_fedora/attribute_methods/write.rb
active-fedora-11.5.2 lib/active_fedora/attribute_methods/write.rb
active-fedora-12.0.0 lib/active_fedora/attribute_methods/write.rb
active-fedora-11.5.0 lib/active_fedora/attribute_methods/write.rb
active-fedora-11.4.1 lib/active_fedora/attribute_methods/write.rb
active-fedora-11.4.0 lib/active_fedora/attribute_methods/write.rb
active-fedora-11.3.1 lib/active_fedora/attribute_methods/write.rb
active-fedora-11.3.0 lib/active_fedora/attribute_methods/write.rb
active-fedora-11.2.0 lib/active_fedora/attribute_methods/write.rb
active-fedora-11.1.6 lib/active_fedora/attribute_methods/write.rb
active-fedora-11.1.5 lib/active_fedora/attribute_methods/write.rb
active-fedora-11.1.4 lib/active_fedora/attribute_methods/write.rb
active-fedora-11.1.3 lib/active_fedora/attribute_methods/write.rb