Skip to content

Commit

Permalink
Simplify _set_value code by inlining _write method.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwz committed Feb 22, 2015
1 parent 869e4be commit 8bbb551
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/jbuilder.rb
Expand Up @@ -274,21 +274,16 @@ def _merge_values(current_value, updates)
end
end

def _write(key, value)
@attributes = {} if _blank?
@attributes[_key(key)] = value
end

def _key(key)
@key_formatter.format(key)
end

def _set_value(key, value)
raise NullError.build(key) if @attributes.nil?
raise ArrayError.build(key) if ::Array === @attributes
return if @ignore_nil && value.nil?
return if _blank?(value)
_write key, value
return if @ignore_nil && value.nil? or _blank?(value)
@attributes = {} if _blank?
@attributes[_key(key)] = value
end

def _map_collection(collection)
Expand Down

0 comments on commit 8bbb551

Please sign in to comment.