Class: Amoeba::Macros::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/amoeba/macros/base.rb

Direct Known Subclasses

HasAndBelongsToMany, HasMany, HasOne

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cloner) ⇒ Base

Returns a new instance of Base.



4
5
6
7
8
# File 'lib/amoeba/macros/base.rb', line 4

def initialize(cloner)
  @cloner     = cloner
  @old_object = cloner.old_object
  @new_object = cloner.new_object
end

Class Method Details

.inherited(klass) ⇒ Object



15
16
17
# File 'lib/amoeba/macros/base.rb', line 15

def inherited(klass)
  ::Amoeba::Macros.add(klass)
end

Instance Method Details

#follow(_relation_name, _association) ⇒ Object



10
11
12
# File 'lib/amoeba/macros/base.rb', line 10

def follow(_relation_name, _association)
  fail "#{self.class.name} doesn't implement `follow`!"
end

#remapped_relation_name(name) ⇒ Object



20
21
22
23
# File 'lib/amoeba/macros/base.rb', line 20

def remapped_relation_name(name)
  return name unless @cloner.amoeba.remap_method
  @old_object.__send__(@cloner.amoeba.remap_method, name.to_sym) || name
end