-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexhaustive_resource.rb
81 lines (65 loc) · 2.3 KB
/
exhaustive_resource.rb
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class ExhaustiveResource < ApplicationResource
class AssertedObject < Types::Object
property :a, Types::Literal.new("a")
property "b-dash", Types::Literal.new(1)
property :c, Types::Maybe.new(Types::String)
property :d_optional, Types::Maybe.new(Types::String), optional: true
end
attribute :asserted_string, Types::String, description: "My asserted string."
attribute :asserted_number, Types::Integer
attribute :asserted_boolean, Types::Boolean
attribute :asserted_null, Types::Null
attribute :asserted_unknown, Types::Unknown
attribute :asserted_object, AssertedObject
attribute :asserted_maybe_object, Types::Maybe.new(AssertedObject)
attribute :asserted_array_record, Types::Array.new(Types::Record.new(Types::Integer))
attribute :asserted_union, Types::Union.new([Types::String, Types::Float])
attribute :with_description, Types::String, description: "This is a provided description."
attribute :inferred_unknown
attribute :uuid
attribute :string
attribute :maybe_string
attribute :text
attribute :integer
attribute :float
attribute :decimal
attribute :datetime
attribute :timestamp
attribute :time
attribute :date
attribute :boolean
attribute :array_string
attribute :maybe_array_string
attribute :json
attribute :jsonb
attribute :daterange
attribute :enum
attribute :virtual_upcased_string
attribute :loljk
attribute :delegated_maybe_string, delegate: :maybe_string
attribute :model_overridden
attribute :resource_overridden
attribute :with_comment
class LinkSchema < Anchor::Types::Object
property :self, Anchor::Types::String
property :some_url, Anchor::Types::String
end
anchor_links_schema LinkSchema
class MetaSchema < Anchor::Types::Object
property :some_count, Anchor::Types::Integer
property :extra_stuff, Anchor::Types::String
end
anchor_meta_schema MetaSchema
def asserted_string = "asserted_string"
def asserted_number = 1
def asserted_boolean = true
def asserted_null = nil
def asserted_unknown = nil
def asserted_object = { a: "a", "b-dash" => 1, c: nil }
def asserted_maybe_object = nil
def asserted_array_record = [{ key: 1 }]
def asserted_union = 2
def inferred_unknown = nil
def resource_overridden = "resource_overridden"
def with_description = "with_description"
end