Class: Machinist::ActiveRecord::Lathe

Inherits:
Lathe
  • Object
show all
Defined in:
lib/machinist/active_record/lathe.rb

Instance Attribute Summary

Attributes inherited from Lathe

#object

Instance Method Summary collapse

Methods inherited from Lathe

#initialize, #method_missing, #sn

Constructor Details

This class inherits a constructor from Machinist::Lathe

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Machinist::Lathe

Instance Method Details

#make_association(attribute, args) ⇒ Object

:nodoc:



12
13
14
15
16
17
18
19
# File 'lib/machinist/active_record/lathe.rb', line 12

def make_association(attribute, args) #:nodoc:
  association = @klass.reflect_on_association(attribute)
  if association
    association.klass.make(*args)
  else
    raise_argument_error(attribute)
  end
end

#make_one_value(attribute, args) ⇒ Object

:nodoc:



3
4
5
6
7
8
9
10
# File 'lib/machinist/active_record/lathe.rb', line 3

def make_one_value(attribute, args) #:nodoc:
  if block_given?
    raise_argument_error(attribute) unless args.empty?
    yield
  else
    make_association(attribute, args)
  end
end