Class: Postgrest::Client
- Inherits:
-
Object
- Object
- Postgrest::Client
- Defined in:
- lib/postgrest/client.rb
Constant Summary collapse
- DEFAULT_SCHEMA =
'public'
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #from(table) ⇒ Object
-
#initialize(url:, headers: {}, schema: DEFAULT_SCHEMA) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(url:, headers: {}, schema: DEFAULT_SCHEMA) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 |
# File 'lib/postgrest/client.rb', line 9 def initialize(url:, headers: {}, schema: DEFAULT_SCHEMA) @url = URI(url) @headers = headers @schema = schema end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
7 8 9 |
# File 'lib/postgrest/client.rb', line 7 def headers @headers end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
7 8 9 |
# File 'lib/postgrest/client.rb', line 7 def schema @schema end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/postgrest/client.rb', line 7 def url @url end |
Instance Method Details
#from(table) ⇒ Object
15 16 17 18 19 |
# File 'lib/postgrest/client.rb', line 15 def from(table) raise MissingTableError if table.nil? || table.empty? Builders::QueryBuilder.new(url: "#{url}/#{table}", headers: headers, schema: schema) end |