Class: Alula::Dcp::BaseResource
- Inherits:
-
Alula::DcpResource
- Object
- Alula::DcpResource
- Alula::Dcp::BaseResource
- Defined in:
- lib/alula/resources/dcp/base_resource.rb
Overview
Base class for DCP resources
Direct Known Subclasses
Config, Config::BusModules, Config::BusModules::BusModule, Config::CommData, Config::CommData::AutoCommTestInterval, Config::CommData::ServerHeartbeats, Config::CommData::ServerKeepAlives, Config::PanelOptions, Config::PanelOptions::AcFailDetectDelay, Config::PanelOptions::EventReportingDelay, Config::PanelOptions::KeyFobButtonFunctions, Config::PanelOptions::MinimumPinSize, Config::PanelOptions::PanelLedBrightness, Config::PanelOptions::PanelMiscOptions, Config::PanelOptions::PanelOptions, Config::PanelOptions::ReportableEventTypesPartitions, Config::PanelOptions::ReportableEventTypesSystem, Config::PanelOptions::SwingerThreshold, Config::PanelOptions::SystemOptions, Config::PanelOptions::TroubleBeepSuppress, Config::PanelOptions::VirtualInterfaceOptions, Config::Partitions, Config::Partitions::Partition, Config::SirenData, Config::SirenData::Siren, Config::Timers, Config::Timers::EntryDelays, Config::Timers::ExitDelays, Config::Timers::SensorSupervisionTime, Config::Timers::SirenTimeout, Config::UsersData, Config::UsersData::DuressPin, Config::UsersData::InstallerPin, Config::UsersData::User
Instance Attribute Summary
Attributes inherited from Alula::DcpResource
#device_id, #dirty_attributes, #errors, #meta, #rate_limit, #raw_data, #values
Class Method Summary collapse
- .api_name(name = nil) ⇒ Object
-
.resource_name(name = nil) ⇒ Object
Infer resource name from classname if not provided.
- .resource_url(device_id, index = nil) ⇒ Object
Instance Method Summary collapse
Methods inherited from Alula::DcpResource
#annotate_errors, #apply_attributes, #as_json, #as_patchable_json, build, class_name, #clone, #construct_from, discriminate_by, discriminator, #errors?, #filter_builder, #find_value, #initialize, #model_name, #pick_value_for_key, #reconstruct_from, #refresh
Constructor Details
This class inherits a constructor from Alula::DcpResource
Class Method Details
.api_name(name = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/alula/resources/dcp/base_resource.rb', line 8 def api_name(name = nil) if name @api_name = name elsif @api_name @api_name else superclass.api_name end end |
.resource_name(name = nil) ⇒ Object
Infer resource name from classname if not provided
19 20 21 22 23 24 25 26 27 |
# File 'lib/alula/resources/dcp/base_resource.rb', line 19 def resource_name(name = nil) if name @resource_name = name elsif @resource_name @resource_name else @resource_name = self.name.split('::').last.downcase.to_sym end end |
.resource_url(device_id, index = nil) ⇒ Object
29 30 31 32 |
# File 'lib/alula/resources/dcp/base_resource.rb', line 29 def resource_url(device_id, index = nil) base_url = "/#{api_name}/v2/helix/#{device_id}/#{resource_name}" index ? "#{base_url}/#{index}" : base_url end |
Instance Method Details
#resource_url(device_id = self.device_id, index = self.index) ⇒ Object
Instance method
38 39 40 |
# File 'lib/alula/resources/dcp/base_resource.rb', line 38 def resource_url(device_id = self.device_id, index = self.index) "/#{self.class.api_name}/v2/helix/#{device_id}/#{self.class.resource_name}/#{index}" end |