Method: Fathom::ContextBehavior::ClassMethods#new

Defined in:
lib/fathom/behaviors/context_behavior.rb

#new(*attrs, &block) ⇒ Object

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
# File 'lib/fathom/behaviors/context_behavior.rb', line 11

def new(*attrs, &block)
  target = attrs.shift
  target ||= default_class.new if default_class
  raise ArgumentError, "You must provide a target object to build this context." unless target
  obj = super(*attrs, &block)
  obj.send(:instance_variable_set, :@object, target)
  obj
end