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.1.8 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.1.7 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.1.6 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.1.5 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.1.4 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.1.3 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.1.1 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.1.0 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.29 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.28 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.27 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.26 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.25 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.24 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.23 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.22 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.21 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.20 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.19 lib/active_resource/associations/builder/belongs_to.rb
embark-journey-0.0.18 lib/active_resource/associations/builder/belongs_to.rb