Class: Fried::Schema::SetAttributeWithoutChecks

Inherits:
Object
  • Object
show all
Defined in:
lib/fried/schema/set_attribute_without_checks.rb

Overview

Set attribute value on object skipping type-checking

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.buildObject



6
7
8
# File 'lib/fried/schema/set_attribute_without_checks.rb', line 6

def self.build
  new
end

.call(obj, attribute, value) ⇒ Object



10
11
12
13
# File 'lib/fried/schema/set_attribute_without_checks.rb', line 10

def self.call(obj, attribute, value)
  instance = build
  instance.(obj, attribute, value)
end

Instance Method Details

#call(obj, attribute, value) ⇒ Object

Returns the passed value.

Parameters:

Returns:

  • (Object)

    the passed value



19
20
21
22
# File 'lib/fried/schema/set_attribute_without_checks.rb', line 19

def call(obj, attribute, value)
  variable = attribute.instance_variable
  obj.instance_variable_set(variable, value)
end