Class: Freemle::Resource
- Inherits:
-
Struct
- Object
- Struct
- Freemle::Resource
- Defined in:
- lib/freemle/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
4 5 6 |
# File 'lib/freemle/resource.rb', line 4 def config @config end |
#plural ⇒ Object
Returns the value of attribute plural
4 5 6 |
# File 'lib/freemle/resource.rb', line 4 def plural @plural end |
#singular ⇒ Object
Returns the value of attribute singular
4 5 6 |
# File 'lib/freemle/resource.rb', line 4 def singular @singular end |
Instance Method Details
#create(payload, &block) ⇒ Hash
Persists a resource on freemle.com, given a payload.
59 60 61 62 |
# File 'lib/freemle/resource.rb', line 59 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.
22 23 24 25 |
# File 'lib/freemle/resource.rb', line 22 def search(query, &block) block = default_handler unless block_given? request.get(params: {query: query}, &block) end |