class Fried::Schema::SetDefaults
Set defaults values for all attributes in schema definitions while ignoring type checking
Attributes
set_attribute_without_checks[RW]
Public Class Methods
build()
click to toggle source
# File lib/fried/schema/set_defaults.rb, line 14 def self.build new.tap do |instance| instance.set_attribute_without_checks = SetAttributeWithoutChecks.build end end
call(schema, obj)
click to toggle source
# File lib/fried/schema/set_defaults.rb, line 20 def self.call(schema, obj) instance = build instance.(schema, obj) end
new()
click to toggle source
# File lib/fried/schema/set_defaults.rb, line 10 def initialize self.set_attribute_without_checks = SetAttributeWithoutChecks.new end
Public Instance Methods
call(schema, obj)
click to toggle source
@param schema [Definition] @param obj [Object] @return [void]
# File lib/fried/schema/set_defaults.rb, line 28 def call(schema, obj) schema.each_attribute do |attribute| value = attribute.extract_default set_attribute_without_checks.(obj, attribute, value) end end