Class: Infreemation::Request
- Inherits:
-
Object
- Object
- Infreemation::Request
- Defined in:
- lib/infreemation/request.rb
Overview
This class represents a FOI or EIR request
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) {|_self| ... } ⇒ Request
constructor
A new instance of Request.
- #save! ⇒ Object
Constructor Details
#initialize(attributes = {}) {|_self| ... } ⇒ Request
Returns a new instance of Request.
26 27 28 29 |
# File 'lib/infreemation/request.rb', line 26 def initialize(attributes = {}) @attributes = attributes yield self if block_given? end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
24 25 26 |
# File 'lib/infreemation/request.rb', line 24 def attributes @attributes end |
Class Method Details
.create!(attributes = {}) ⇒ Object
13 14 15 |
# File 'lib/infreemation/request.rb', line 13 def create!(attributes = {}) new(attributes, &:save!) end |
.path ⇒ Object
9 10 11 |
# File 'lib/infreemation/request.rb', line 9 def path '/foi/' end |
.where(options = {}) ⇒ Object
17 18 19 20 21 |
# File 'lib/infreemation/request.rb', line 17 def where( = {}) type = .fetch(:rt).downcase.to_sym requests_data = API.get(path, ).dig(type, :request) || [] requests_data.map { |attributes| new(attributes) } end |
Instance Method Details
#save! ⇒ Object
31 32 33 34 |
# File 'lib/infreemation/request.rb', line 31 def save! @attributes.merge!(API.post(self.class.path, attributes)) true end |