Class: ActiveFactory::Linker

Inherits:
Object
  • Object
show all
Defined in:
lib/active_factory.rb

Overview

provides syntax to create associations between models

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container, use_association = nil) ⇒ Linker

Returns a new instance of Linker.



258
259
260
261
262
263
264
265
# File 'lib/active_factory.rb', line 258

def initialize container, use_association = nil
  @container = container
  @use_association = use_association

  @entries = container.entries
  @model_class = container.factory.model_class
  @prefer_associations = container.factory.prefer_associations
end

Instance Attribute Details

#entriesObject

Returns the value of attribute entries.



267
268
269
# File 'lib/active_factory.rb', line 267

def entries
  @entries
end

#model_classObject

Returns the value of attribute model_class.



267
268
269
# File 'lib/active_factory.rb', line 267

def model_class
  @model_class
end

Instance Method Details

#-(that) ⇒ Object



269
270
271
272
273
274
275
276
277
278
279
# File 'lib/active_factory.rb', line 269

def - that
  case that
    when Linker
      associate that
      that
    when Symbol
      Linker.new @container, that
    else
      raise "cannot associate with #{that.inspect}"
  end
end