Sha256: 740c3d3e39874e1eecbcb1575f5a5e20d99424b013f39f6cc0c03ddbdff901cf

Contents?: true

Size: 763 Bytes

Versions: 33

Compression:

Stored size: 763 Bytes

Contents

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

    def self.constructable?
      true
    end

    def self.define_accessors(model, reflection)
      super
      define_constructors(model.generated_association_methods, reflection.name)  if 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

33 entries across 33 versions & 1 rubygems

Version Path
active-fedora-9.0.8 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.5.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.4.3 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.4.2 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.4.1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.4.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.3.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.2.1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.2.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.2.0.rc2 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.2.0.rc1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.1.2 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.1.1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.1.0 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.1.0.rc1 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.0.6 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.0.5 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.0.4 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.0.3 lib/active_fedora/associations/builder/singular_association.rb
active-fedora-9.0.2 lib/active_fedora/associations/builder/singular_association.rb