Class: Bricks::Adapters::ActiveRecord::Association

Inherits:
Object
  • Object
show all
Defined in:
lib/bricks/adapters/active_record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, kind) ⇒ Association

Returns a new instance of Association.



10
11
12
13
14
15
16
17
# File 'lib/bricks/adapters/active_record.rb', line 10

def initialize(klass, kind)
  @class = klass
  @type  = case kind
           when :belongs_to;                         :one
           when :has_many, :has_and_belongs_to_many; :many
           else "Unknown AR association type: #{kind}."
           end
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/bricks/adapters/active_record.rb', line 8

def type
  @type
end

Instance Method Details

#klassObject



19
20
21
# File 'lib/bricks/adapters/active_record.rb', line 19

def klass
  @class
end