Sha256: f23b9ec5877d482afecab9634fb8dc4e0a67f4f9a381e049a976b6baa7061a08
Contents?: true
Size: 970 Bytes
Versions: 6
Compression:
Stored size: 970 Bytes
Contents
# encoding: UTF-8 module BeerDb::Models class BeerSerializer def initialize( beer ) @beer = beer end attr_reader :beer def as_json brewery = {} if beer.brewery.present? brewery = { key: beer.brewery.key, title: beer.brewery.title } end tags = [] if beer.tags.present? beer.tags.each { |tag| tags << tag.key } end country = { key: beer.country.key, title: beer.country.title } data = { key: beer.key, title: beer.title, synonyms: beer.synonyms, abv: beer.abv, srm: beer.srm, og: beer.og, tags: tags, brewery: brewery, country: country } data.to_json end end # class BeerSerializer end # module BeerDb::Models
Version data entries
6 entries across 6 versions & 1 rubygems