Sha256: 6bab620df1369785797ef7e18320096f95dfefca4eb70ca6fa279ede1e14def4
Contents?: true
Size: 1.04 KB
Versions: 6
Compression:
Stored size: 1.04 KB
Contents
# encoding: UTF-8 module BeerDb::Models class BrewerySerializer def initialize( brewery ) @brewery = brewery end attr_reader :brewery def as_json beers = [] brewery.beers.each do |b| beers << { key: b.key, title: b.title } end tags = [] if brewery.tags.present? brewery.tags.each { |tag| tags << tag.key } end country = { key: brewery.country.key, title: brewery.country.title } data = { key: brewery.key, title: brewery.title, synonyms: brewery.synonyms, since: brewery.since, address: brewery.address, web: brewery.web, prod: brewery.prod, # (estimated) annual production in hl e.g. 2_000 hl tags: tags, beers: beers, country: country } data.to_json end end # class BrewerySerializer end # module BeerDb::Models
Version data entries
6 entries across 6 versions & 1 rubygems