Sha256: 437c62a1ef66e2c8fc95bbafd601d94c8bfb1864732aed69742a82ae87d6aa5f
Contents?: true
Size: 1.04 KB
Versions: 18
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true require_relative './collector/game' class Collector include Arstotzka MALE = 'male' FEMALE = 'female' attr_reader :hash expose :full_name, :age, path: :person, json: :hash expose :gender, path: :person, type: :gender, cached: true, json: :hash expose :car_names, flatten: true, compact: false, json: :hash, default: 'MissingName', full_path: 'collections.cars.units.nick_name' expose :finished_games, json: :hash, flatten: true, klass: Collector::Game, after: :filter_finished, compact: true, full_path: 'collections.games.titles' def initialize(hash = {}) @hash = hash end private def filter_finished(games) games.select(&:finished?) end end module Arstotzka module TypeCast def to_gender(value) case value when 'man' Collector::MALE when 'woman' Collector::FEMALE else raise 'invalid gender' end end end end
Version data entries
18 entries across 18 versions & 1 rubygems