Class: PgGraphQl::Schema::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/pggraphql.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fieldsObject

Returns the value of attribute fields.



88
89
90
# File 'lib/pggraphql.rb', line 88

def fields
  @fields
end

#filterObject

Returns the value of attribute filter.



88
89
90
# File 'lib/pggraphql.rb', line 88

def filter
  @filter
end

Returns the value of attribute links.



88
89
90
# File 'lib/pggraphql.rb', line 88

def links
  @links
end

#nameObject

Returns the value of attribute name.



88
89
90
# File 'lib/pggraphql.rb', line 88

def name
  @name
end

#order_byObject

Returns the value of attribute order_by.



88
89
90
# File 'lib/pggraphql.rb', line 88

def order_by
  @order_by
end

#schemaObject (readonly)

Returns the value of attribute schema.



89
90
91
# File 'lib/pggraphql.rb', line 89

def schema
  @schema
end

#tableObject

Returns the value of attribute table.



88
89
90
# File 'lib/pggraphql.rb', line 88

def table
  @table
end

Instance Method Details



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