Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
nepalez committed Feb 4, 2017
1 parent 212da4b commit 9280434
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
10 changes: 10 additions & 0 deletions lib/dry/initializer/attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,15 @@ def validate_coercer
return if coercer.nil? || coercer.respond_to?(:call)
fail TypeConstraintError.new(source, coercer)
end

def default_hash(type)
default ? { :"#{type}_#{source}" => default } : {}
end

def coercer_hash(type)
return {} unless coercer
value = proc { |v| v == Dry::Initializer::UNDEFINED ? v : coercer.(v) }
{ :"#{type}_#{source}" => value }
end
end
end
6 changes: 2 additions & 4 deletions lib/dry/initializer/option.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ def fast_setter

# part of __defaults__
def default_hash
default ? { :"option_#{source}" => default } : {}
super :option
end

# part of __coercers__
def coercer_hash
return {} unless coercer
value = proc { |v| v == Dry::Initializer::UNDEFINED ? v : coercer.(v) }
{ :"option_#{source}" => value }
super :option
end

private
Expand Down
6 changes: 2 additions & 4 deletions lib/dry/initializer/param.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ def fast_setter

# part of __defaults__
def default_hash
default ? { :"param_#{target}" => default } : {}
super :param
end

# part of __coercers__
def coercer_hash
return {} unless coercer
value = proc { |v| v == Dry::Initializer::UNDEFINED ? v : coercer.(v) }
{ :"param_#{target}" => value }
super :param
end

private
Expand Down

0 comments on commit 9280434

Please sign in to comment.