File: data.rb

package info (click to toggle)
ruby-graphql 2.5.19-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 13,868 kB
  • sloc: ruby: 80,420; ansic: 1,808; yacc: 845; javascript: 480; makefile: 6
file content (45 lines) | stat: -rw-r--r-- 1,163 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true
require 'ostruct'
module Dummy
  module Data
    Cheese = Struct.new(:id, :flavor, :origin, :fat_content, :source) do
      def ==(other)
        # This is buggy on purpose -- it shouldn't be called during execution.
        other.id == id
      end

      # Alias for when this is treated as milk in EdibleAsMilkInterface
      def fatContent # rubocop:disable Naming/MethodName
        fat_content
      end
    end

    Milk = Struct.new(:id, :fat_content, :origin, :source, :flavors)
    Cow = Struct.new(:id, :name, :last_produced_dairy)
    Goat = Struct.new(:id, :name, :last_produced_dairy)
  end

  CHEESES = {
    1 => Data::Cheese.new(1, "Brie", "France", 0.19, 1),
    2 => Data::Cheese.new(2, "Gouda", "Netherlands", 0.3, 1),
    3 => Data::Cheese.new(3, "Manchego", "Spain", 0.065, "SHEEP")
  }

  MILKS = {
    1 => Data::Milk.new(1, 0.04, "Antiquity", 1, ["Natural", "Chocolate", "Strawberry"]),
  }

  DAIRY = OpenStruct.new(
    id: 1,
    cheese: CHEESES[1],
    milks: [MILKS[1]]
  )

  COWS = {
    1 => Data::Cow.new(1, "Billy", MILKS[1])
  }

  GOATS = {
    1 => Data::Goat.new(1, "Gilly", MILKS[1]),
  }
end