Class: Cephalopod::Repos::Base
- Inherits:
-
Object
- Object
- Cephalopod::Repos::Base
- Defined in:
- lib/cephalopod/repos/base.rb
Direct Known Subclasses
V1::ElectricityMeterPoints::Consumption::Collection, V1::ElectricityMeterPoints::Resource, V1::GSP::Resource, V1::GasMeterPoints::Consumption::Collection, V1::GasMeterPoints::Resource, V1::Products::Collection, V1::Products::Resource, V1::Tariffs::Electricity::DayUnitRates::Collection, V1::Tariffs::Electricity::NightUnitRates::Collection, V1::Tariffs::Electricity::StandardUnitRates::Collection, V1::Tariffs::Electricity::StandingCharges::Collection, V1::Tariffs::Gas::StandardUnitRates::Collection, V1::Tariffs::Gas::StandingCharges::Collection
Class Attribute Summary collapse
-
.default_model ⇒ Object
Returns the value of attribute default_model.
-
.default_resource_route ⇒ Object
Returns the value of attribute default_resource_route.
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#resource_route ⇒ Object
readonly
Returns the value of attribute resource_route.
Class Method Summary collapse
- .model(model) ⇒ Object
- .resource_route(path) ⇒ Object
- .route ⇒ Object
- .unsupported(*methods) ⇒ Object
Instance Method Summary collapse
- #get(method: :get, headers: {}, query: {}, body: nil, **params, &block) ⇒ Object
-
#initialize(client: Cephalopod.client, model: default_model, resource_route: default_resource_route) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(client: Cephalopod.client, model: default_model, resource_route: default_resource_route) ⇒ Base
Returns a new instance of Base.
30 31 32 33 34 |
# File 'lib/cephalopod/repos/base.rb', line 30 def initialize(client: Cephalopod.client, model: default_model, resource_route: default_resource_route) @client, @model, @resource_route = client, model, resource_route end |
Class Attribute Details
.default_model ⇒ Object
Returns the value of attribute default_model.
5 6 7 |
# File 'lib/cephalopod/repos/base.rb', line 5 def default_model @default_model end |
.default_resource_route ⇒ Object
Returns the value of attribute default_resource_route.
5 6 7 |
# File 'lib/cephalopod/repos/base.rb', line 5 def default_resource_route @default_resource_route end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
28 29 30 |
# File 'lib/cephalopod/repos/base.rb', line 28 def model @model end |
#resource_route ⇒ Object (readonly)
Returns the value of attribute resource_route.
28 29 30 |
# File 'lib/cephalopod/repos/base.rb', line 28 def resource_route @resource_route end |
Class Method Details
.model(model) ⇒ Object
7 8 9 |
# File 'lib/cephalopod/repos/base.rb', line 7 def model(model) self.default_model = model end |
.resource_route(path) ⇒ Object
11 12 13 |
# File 'lib/cephalopod/repos/base.rb', line 11 def resource_route(path) self.default_resource_route = path end |
.route ⇒ Object
21 22 23 |
# File 'lib/cephalopod/repos/base.rb', line 21 def route @route ||= Mustermann.new(default_resource_route) end |
.unsupported(*methods) ⇒ Object
15 16 17 18 19 |
# File 'lib/cephalopod/repos/base.rb', line 15 def unsupported(*methods) self.class_eval do methods.each { |method| alias_method method, :undefined } end end |
Instance Method Details
#get(method: :get, headers: {}, query: {}, body: nil, **params, &block) ⇒ Object
36 37 38 |
# File 'lib/cephalopod/repos/base.rb', line 36 def get(method: :get, headers: {}, query: {}, body: nil, **params, &block) @get ||= parse_response(@client.run_request(method, build_path(query: query, **params), body, headers, &block)) end |