Class: PgGraphQl::Schema::Type
- Inherits:
-
Object
- Object
- PgGraphQl::Schema::Type
- Defined in:
- lib/pggraphql.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#filter ⇒ Object
Returns the value of attribute filter.
-
#links ⇒ Object
Returns the value of attribute links.
-
#name ⇒ Object
Returns the value of attribute name.
-
#order_by ⇒ Object
Returns the value of attribute order_by.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
- #create_link(name, many, opts) ⇒ Object
-
#initialize(schema, name) ⇒ Type
constructor
A new instance of Type.
- #many(name, opts = {}) ⇒ Object
- #one(name, opts = {}) ⇒ Object
Constructor Details
#initialize(schema, name) ⇒ Type
Returns a new instance of Type.
90 91 92 93 94 95 96 97 98 |
# File 'lib/pggraphql.rb', line 90 def initialize(schema, name) @schema = schema @name = name @table = name.to_s.pluralize.to_sym @fields = [:id] @filter = nil @order_by = nil @links = {} end |
Instance Attribute Details
#fields ⇒ Object
Returns the value of attribute fields.
88 89 90 |
# File 'lib/pggraphql.rb', line 88 def fields @fields end |
#filter ⇒ Object
Returns the value of attribute filter.
88 89 90 |
# File 'lib/pggraphql.rb', line 88 def filter @filter end |
#links ⇒ Object
Returns the value of attribute links.
88 89 90 |
# File 'lib/pggraphql.rb', line 88 def links @links end |
#name ⇒ Object
Returns the value of attribute name.
88 89 90 |
# File 'lib/pggraphql.rb', line 88 def name @name end |
#order_by ⇒ Object
Returns the value of attribute order_by.
88 89 90 |
# File 'lib/pggraphql.rb', line 88 def order_by @order_by end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
89 90 91 |
# File 'lib/pggraphql.rb', line 89 def schema @schema end |
#table ⇒ Object
Returns the value of attribute table.
88 89 90 |
# File 'lib/pggraphql.rb', line 88 def table @table end |
Instance Method Details
#create_link(name, many, opts) ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/pggraphql.rb', line 105 def create_link(name, many, opts) link = @links[name] = Link.new(self, name, many) opts.each_pair do |key, val| link.send(:"#{key}=", val) end link end |
#many(name, opts = {}) ⇒ Object
102 103 104 |
# File 'lib/pggraphql.rb', line 102 def many(name, opts={}) create_link(name, true, opts) end |
#one(name, opts = {}) ⇒ Object
99 100 101 |
# File 'lib/pggraphql.rb', line 99 def one(name, opts={}) create_link(name, false, opts) end |