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, Zone
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
38
39
40
41
42
43
44
45
46
|
# File 'lib/hcloud/resource.rb', line 38
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
52
53
54
|
# File 'lib/hcloud/resource.rb', line 52
def self.client
HCloud::Client.connection
end
|
.resource_name ⇒ Object
48
49
50
|
# File 'lib/hcloud/resource.rb', line 48
def self.resource_name
name.demodulize.underscore
end
|
Instance Method Details
#==(other) ⇒ Object
34
35
36
|
# File 'lib/hcloud/resource.rb', line 34
def ==(other)
id && id == other.id
end
|
#inspect ⇒ Object
24
25
26
|
# File 'lib/hcloud/resource.rb', line 24
def inspect
"#<#{self.class} #{attributes.filter_map { |name, value| "#{name}: #{value.inspect}" }.join(', ')}>"
end
|
#mutable? ⇒ Boolean
18
19
20
|
# File 'lib/hcloud/resource.rb', line 18
def mutable?
true
end
|
#to_h ⇒ Object
28
29
30
31
32
|
# File 'lib/hcloud/resource.rb', line 28
def to_h
{
id: id,
}
end
|