Class: RailsClafer::Association

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src, dst, dst_card) ⇒ Association

Returns a new instance of Association.



13
14
15
# File 'lib/rails_clafer/association.rb', line 13

def initialize(src, dst, dst_card)
  @src, @dst, @dst_card = src, dst, dst_card
end

Instance Attribute Details

#dstObject

Returns the value of attribute dst.



12
13
14
# File 'lib/rails_clafer/association.rb', line 12

def dst
  @dst
end

#dst_cardObject

Returns the value of attribute dst_card.



12
13
14
# File 'lib/rails_clafer/association.rb', line 12

def dst_card
  @dst_card
end

#ref_nameObject

Returns the value of attribute ref_name.



12
13
14
# File 'lib/rails_clafer/association.rb', line 12

def ref_name
  @ref_name
end

#srcObject

Returns the value of attribute src.



12
13
14
# File 'lib/rails_clafer/association.rb', line 12

def src
  @src
end

Class Method Details

.from_ar_assoc(src_class, ar_assoc) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/rails_clafer/association.rb', line 4

def from_ar_assoc(src_class, ar_assoc)
  card = Card.from_ar_assoc ar_assoc
  assoc = new ClaferModel.claferize_name(src_class.name),
    ClaferModel.claferize_name(ar_assoc.klass.name), card
  assoc.ref_name = ClaferModel.claferize_name ar_assoc.name if ar_assoc.name
  assoc
end