Sha256: 9b9f1356975d2cd7edfe144eff289614c512a1b8bfab477cf446708d276631e1

Contents?: true

Size: 768 Bytes

Versions: 70

Compression:

Stored size: 768 Bytes

Contents

module ActiveFedora::Associations::Builder
  class SingularAssociation < Association #:nodoc:
    def self.valid_options(options)
      super + [:dependent, :inverse_of, :required]
    end

    def self.define_accessors(model, reflection)
      super
      define_constructors(model.generated_association_methods, reflection.name) if reflection.constructable?
    end

    def self.define_constructors(mixin, 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

70 entries across 70 versions & 1 rubygems

Version Path
active-fedora-11.1.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-10.3.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-11.0.1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-11.0.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-10.3.0.rc2 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-11.0.0.rc7 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-10.3.0.rc1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-11.0.0.rc6 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-10.2.1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-11.0.0.rc5 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-11.0.0.rc4 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-10.2.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-11.0.0.rc3 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-11.0.0.rc2 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-11.0.0.rc1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-10.1.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-10.1.0.rc1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-10.0.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-10.0.0.beta4 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-10.0.0.beta3 lib/active_fedora/associations/builder/singular_association.rb