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-13.3.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-12.2.4 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-13.2.7 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-13.2.5 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-13.2.4 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-12.2.3 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-13.2.3 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-13.2.2 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-13.2.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-13.1.3 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-11.5.6 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-12.2.2 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-11.2.1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-12.2.1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-12.0.3 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-11.5.5 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-13.1.2 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-13.1.1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-13.1.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-13.0.0 lib/active_fedora/associations/builder/singular_association.rb