Module: Shrinker::Serializer
Instance Method Summary collapse
-
#from_json(content) ⇒ Object
symbolize keys from the json if with_indifferent_access exists.
- #to_hash(raw_url, attributes = {}) ⇒ Object
- #to_json(raw_url, attributes = {}) ⇒ Object
Instance Method Details
#from_json(content) ⇒ Object
symbolize keys from the json if with_indifferent_access exists
14 15 16 17 18 |
# File 'lib/shrinker/serializer.rb', line 14 def from_json(content) hash = JSON.parse(content) hash = hash.with_indifferent_access if hash.respond_to?(:with_indifferent_access) hash end |
#to_hash(raw_url, attributes = {}) ⇒ Object
9 10 11 |
# File 'lib/shrinker/serializer.rb', line 9 def to_hash(raw_url, attributes = {}) {:url => raw_url, :attributes => (attributes || {})} end |
#to_json(raw_url, attributes = {}) ⇒ Object
5 6 7 |
# File 'lib/shrinker/serializer.rb', line 5 def to_json(raw_url, attributes = {}) to_hash(raw_url, attributes).to_json end |