Class: ActiveAws::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/active_aws/base.rb
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(**params) {|_self| ... } ⇒ Base
Returns a new instance of Base.
33
34
35
36
37
38
39
|
# File 'lib/active_aws/base.rb', line 33
def initialize( **params )
self.class.attributes.each do |k|
method = "#{k}="
self.send(method, params[k]) if params[k].present?
end
yield( self ) if block_given?
end
|
Class Attribute Details
.attributes ⇒ Object
Returns the value of attribute attributes.
10
11
12
|
# File 'lib/active_aws/base.rb', line 10
def attributes
@attributes
end
|
Returns the value of attribute root_configure.
11
12
13
|
# File 'lib/active_aws/base.rb', line 11
def root_configure
@root_configure
end
|
Class Method Details
.inherited(klass) ⇒ Object
13
14
15
|
# File 'lib/active_aws/base.rb', line 13
def inherited( klass )
klass.attributes = @attributes
end
|
.load_config!(args) ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/active_aws/base.rb', line 17
def load_config!( args )
@config = if args.is_a? Hash
args
elsif File.file?( args.to_s )
YAML.load_file( args.to_s )
else
raise ArgumentError
end
@root_configure = Configure.new( **@config.symbolize_keys )
end
|
Instance Method Details
#name ⇒ Object
41
42
43
44
45
|
# File 'lib/active_aws/base.rb', line 41
def name
name_tag = tags.detect{|t| t[:key].to_s == "Name"}
return nil unless name_tag
name_tag[:value]
end
|
#to_h ⇒ Object
47
48
49
50
51
52
|
# File 'lib/active_aws/base.rb', line 47
def to_h
self.class.attributes.reduce({}) do |acc,k|
acc[k] = self.send( k )
acc
end
end
|