Sha256: c5ef04d2ec3cb4e0b6f66d800faa5a735549ad1a1855860f160203c0024ca035

Contents?: true

Size: 738 Bytes

Versions: 33

Compression:

Stored size: 738 Bytes

Contents

module ActiveFedora::Associations::Builder
  class SingularAssociation < Association #:nodoc:
    self.valid_options += [:dependent, :counter_cache, :inverse_of]

    def constructable?
      true
    end

    def define_accessors
      super
      define_constructors if constructable?
    end

    private

      def define_constructors
        name = self.name

        mixin.redefine_method("build_#{name}") do |*params|
          association(name).build(*params)
        end

        mixin.redefine_method("create_#{name}") do |*params|
          association(name).create(*params)
        end

        mixin.redefine_method("create_#{name}!") do |*params|
          association(name).create!(*params)
        end
      end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
active-fedora-8.7.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-8.6.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-8.5.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-8.4.2 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-8.4.1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-7.3.1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-7.3.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-8.4.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-8.3.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-8.2.2 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-8.2.1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-8.2.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-7.2.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-8.1.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-8.0.1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-8.0.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-8.0.0.rc3 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-8.0.0.rc2 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-8.0.0.rc1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-7.1.2 lib/active_fedora/associations/builder/singular_association.rb