Sha256: 8d300c650ea86038452cf0095002fe679002b5e8be9ea33580d9a41d8e92bde2

Contents?: true

Size: 562 Bytes

Versions: 30

Compression:

Stored size: 562 Bytes

Contents

module ActiveResource::Associations::Builder 
  class BelongsTo < Association
    self.valid_options += [:foreign_key, :embed]

    self.macro = :belongs_to

    def build
      validate_options
      embed = options.delete(:embed)

      reflection = model.create_reflection(self.class.macro, name, options)
      model.defines_belongs_to_finder_method(reflection.name, reflection.klass, reflection.foreign_key)

      model.defines_belongs_to_embed(reflection.name, reflection.klass, reflection.foreign_key) if embed

      return reflection
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
embark-journey-0.0.17 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.16 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.15 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.14 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.13 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.12 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.11 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.10 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.9 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.8 lib/active_resource/associations/builder/belongs_to.rb