Module: DNApi::Component
- Included in:
- DNApi::Components::Addons, DNApi::Components::Apache, DNApi::Components::AppMetadata, DNApi::Components::Cloudkick, DNApi::Components::EBSVolume, DNApi::Components::EncryptedBackup, DNApi::Components::EnvironmentMetadata, DNApi::Components::EphemeralVolume, DNApi::Components::Exim, DNApi::Components::GodMonitor, DNApi::Components::JRuby187, DNApi::Components::JRuby192, DNApi::Components::Metadata, DNApi::Components::Nagios, DNApi::Components::Newrelic, DNApi::Components::NodeJS, DNApi::Components::PHP, DNApi::Components::Passenger3, DNApi::Components::REE, DNApi::Components::Rubinius, DNApi::Components::Rubinius19, DNApi::Components::Ruby186, DNApi::Components::Ruby187, DNApi::Components::Ruby192, DNApi::Components::Ruby193, DNApi::Components::Rubygems, DNApi::Components::Ssmtp, DNApi::Components::Stunneled, DNApi::Components::V8
- Defined in:
- lib/dnapi/component.rb
Defined Under Namespace
Modules: ClassExt
Classes: NoSuchComponent
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.[](key) ⇒ Object
29
30
31
|
# File 'lib/dnapi/component.rb', line 29
def self.[](key)
components.detect {|c| c.key_id == key }
end
|
.components ⇒ Object
25
26
27
|
# File 'lib/dnapi/component.rb', line 25
def self.components
@components ||= []
end
|
.from(values) ⇒ Object
33
34
35
36
37
|
# File 'lib/dnapi/component.rb', line 33
def self.from(values)
if klass = self[values.delete('key').to_sym]
klass.new(values)
end
end
|
.included(receiver) ⇒ Object
19
20
21
22
23
|
# File 'lib/dnapi/component.rb', line 19
def self.included(receiver)
components << receiver
receiver.send(:attr_accessor, :parent)
receiver.extend ClassExt
end
|
Instance Method Details
#can_belong_to?(model) ⇒ Boolean
47
48
49
|
# File 'lib/dnapi/component.rb', line 47
def can_belong_to?(model)
self.class.parent === model
end
|
#key ⇒ Object
39
40
41
|
# File 'lib/dnapi/component.rb', line 39
def key
self::class.key_id
end
|
#to_hash ⇒ Object
43
44
45
|
# File 'lib/dnapi/component.rb', line 43
def to_hash
super.merge('key' => key)
end
|