Class: AWS::Core::Resource::Attribute
- Inherits:
-
Object
- Object
- AWS::Core::Resource::Attribute
- Defined in:
- lib/aws/core/resource.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#request_types ⇒ Object
readonly
Returns the value of attribute request_types.
Instance Method Summary collapse
- #get_as ⇒ Object
-
#initialize(name, options = {}) ⇒ Attribute
constructor
A new instance of Attribute.
- #mutable? ⇒ Boolean
- #set_as ⇒ Object
- #static? ⇒ Boolean
- #translate_input_value(value) ⇒ Object
- #translate_output_value(value) ⇒ Object
- #translates_input(&block) ⇒ Object
- #translates_output(options = {}, &block) ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Attribute
Returns a new instance of Attribute.
282 283 284 285 286 |
# File 'lib/aws/core/resource.rb', line 282 def initialize name, = {} @name = name @options = @request_types = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
288 289 290 |
# File 'lib/aws/core/resource.rb', line 288 def name @name end |
#request_types ⇒ Object (readonly)
Returns the value of attribute request_types.
290 291 292 |
# File 'lib/aws/core/resource.rb', line 290 def request_types @request_types end |
Instance Method Details
#get_as ⇒ Object
292 293 294 |
# File 'lib/aws/core/resource.rb', line 292 def get_as @get_as ||= (@options[:get_as] || @options[:as] || name) end |
#mutable? ⇒ Boolean
300 301 302 |
# File 'lib/aws/core/resource.rb', line 300 def mutable? @options[:mutable] == true end |
#set_as ⇒ Object
296 297 298 |
# File 'lib/aws/core/resource.rb', line 296 def set_as @set_as ||= (@options[:set_as] || @options[:as] || name) end |
#static? ⇒ Boolean
304 305 306 |
# File 'lib/aws/core/resource.rb', line 304 def static? @options[:static] == true end |
#translate_input_value(value) ⇒ Object
317 318 319 |
# File 'lib/aws/core/resource.rb', line 317 def translate_input_value value @input_translator ? @input_translator.call(value) : value end |
#translate_output_value(value) ⇒ Object
321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'lib/aws/core/resource.rb', line 321 def translate_output_value value # by default nil values are not translated return nil if value.nil? and @translates_nil != true case when @options[:to_sym] then value.tr('-','_').downcase.to_sym when @options[:timestamp] then Time.at(value.to_i) when @output_translator then @output_translator.call(value) else value end end |
#translates_input(&block) ⇒ Object
308 309 310 |
# File 'lib/aws/core/resource.rb', line 308 def translates_input &block @input_translator = block end |
#translates_output(options = {}, &block) ⇒ Object
312 313 314 315 |
# File 'lib/aws/core/resource.rb', line 312 def translates_output = {}, &block @translates_nil = [:nil] @output_translator = block end |