Class: HCloud::Resource
- Inherits:
-
Object
show all
- Includes:
- ActiveModel::AttributeAssignment, ActiveModel::Attributes
- Defined in:
- lib/hcloud/resource.rb
Direct Known Subclasses
Action, Certificate, Datacenter, Firewall, FloatingIP, ISO, Image, LoadBalancer, LoadBalancerType, Location, Metadata, Network, PlacementGroup, Pricing, PrimaryIP, SSHKey, Server, ServerType, StorageBox, StorageBoxSnapshot, StorageBoxSubaccount, StorageBoxType, Volume
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}) ⇒ Resource
Returns a new instance of Resource.
12
13
14
15
16
|
# File 'lib/hcloud/resource.rb', line 12
def initialize(attributes = {})
super()
assign_attributes(attributes) if attributes
end
|
Class Method Details
.attribute(name, *args, deprecated: false, **kwargs) ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/hcloud/resource.rb', line 34
def self.attribute(name, *args, deprecated: false, **kwargs)
super(name, *args, **kwargs)
define_method(name) do |**params|
warn "[DEPRECATION] Field \"#{name}\" on #{self.class.name} is deprecated." if deprecated
super(**params)
end
end
|
.client ⇒ Object
48
49
50
|
# File 'lib/hcloud/resource.rb', line 48
def self.client
HCloud::Client.connection
end
|
.resource_name ⇒ Object
44
45
46
|
# File 'lib/hcloud/resource.rb', line 44
def self.resource_name
name.demodulize.underscore
end
|
Instance Method Details
#==(other) ⇒ Object
30
31
32
|
# File 'lib/hcloud/resource.rb', line 30
def ==(other)
id && id == other.id
end
|
#inspect ⇒ Object
20
21
22
|
# File 'lib/hcloud/resource.rb', line 20
def inspect
"#<#{self.class} #{attributes.filter_map { |name, value| "#{name}: #{value.inspect}" }.join(', ')}>"
end
|
#to_h ⇒ Object
24
25
26
27
28
|
# File 'lib/hcloud/resource.rb', line 24
def to_h
{
id: id,
}
end
|