Class: Freemle::Client::Resource
- Inherits:
-
Struct
- Object
- Struct
- Freemle::Client::Resource
- Defined in:
- lib/freemle/client/resource.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#plural ⇒ Object
Returns the value of attribute plural.
-
#singular ⇒ Object
Returns the value of attribute singular.
Instance Method Summary collapse
-
#create(payload, &block) ⇒ Hash
Persists a resource on freemle.com, given a payload.
-
#search(query, &block) ⇒ Array<Hash>
Performs a search on this resource, given a query.
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config
5 6 7 |
# File 'lib/freemle/client/resource.rb', line 5 def config @config end |
#plural ⇒ Object
Returns the value of attribute plural
5 6 7 |
# File 'lib/freemle/client/resource.rb', line 5 def plural @plural end |
#singular ⇒ Object
Returns the value of attribute singular
5 6 7 |
# File 'lib/freemle/client/resource.rb', line 5 def singular @singular end |
Instance Method Details
#create(payload, &block) ⇒ Hash
Persists a resource on freemle.com, given a payload.
60 61 62 63 |
# File 'lib/freemle/client/resource.rb', line 60 def create(payload, &block) block = default_handler unless block_given? request.post(json.generate({singular => payload}), &block) end |
#search(query, &block) ⇒ Array<Hash>
Performs a search on this resource, given a query.
23 24 25 26 |
# File 'lib/freemle/client/resource.rb', line 23 def search(query, &block) block = default_handler unless block_given? request.get(params: {query: query}, &block) end |