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, Volume
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}) ⇒ Resource
Returns a new instance of Resource.
11
12
13
14
15
|
# File 'lib/hcloud/resource.rb', line 11
def initialize(attributes = {})
super()
assign_attributes(attributes) if attributes
end
|
Class Method Details
.attribute(name, *args, deprecated: false, **kwargs) ⇒ Object
33
34
35
36
37
38
39
40
41
|
# File 'lib/hcloud/resource.rb', line 33
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
47
48
49
|
# File 'lib/hcloud/resource.rb', line 47
def self.client
HCloud::Client.connection
end
|
.resource_name ⇒ Object
43
44
45
|
# File 'lib/hcloud/resource.rb', line 43
def self.resource_name
name.demodulize.underscore
end
|
Instance Method Details
#==(other) ⇒ Object
29
30
31
|
# File 'lib/hcloud/resource.rb', line 29
def ==(other)
id && id == other.id
end
|
#inspect ⇒ Object
19
20
21
|
# File 'lib/hcloud/resource.rb', line 19
def inspect
"#<#{self.class} #{attributes.filter_map { |name, value| "#{name}: #{value.inspect}" }.join(', ')}>"
end
|
#to_h ⇒ Object
23
24
25
26
27
|
# File 'lib/hcloud/resource.rb', line 23
def to_h
{
id: id,
}
end
|