module Aws::Lex::Conversation::Type::Base::ClassMethods
Public Instance Methods
attributes()
click to toggle source
# File lib/aws/lex/conversation/type/base.rb, line 115 def attributes @attributes ||= mapping.keys end
computed_property(attribute, opts = {}, &block)
click to toggle source
# File lib/aws/lex/conversation/type/base.rb, line 74 def computed_property(attribute, opts = {}, &block) attr_writer(attribute) if opts.fetch(:virtual) { false } virtual_attributes << attribute else mapping[attribute] = attribute end # dynamically memoize the result define_method(attribute) do instance_variable_get("@#{attribute}") || instance_variable_set("@#{attribute}", block.call(self)) end end
float!(nilable: false)
click to toggle source
# File lib/aws/lex/conversation/type/base.rb, line 66 def float!(nilable: false) nilable ? ->(v) { v&.to_f } : ->(v) { v.to_f } end
integer!(nilable: false)
click to toggle source
# File lib/aws/lex/conversation/type/base.rb, line 62 def integer!(nilable: false) nilable ? ->(v) { v&.to_i } : ->(v) { v.to_i } end
mapping()
click to toggle source
# File lib/aws/lex/conversation/type/base.rb, line 123 def mapping @mapping ||= {} end
optional(attribute, opts = {})
click to toggle source
# File lib/aws/lex/conversation/type/base.rb, line 94 def optional(attribute, opts = {}) property(attribute, opts.merge(allow_nil: true)) end
property(attribute, opts = {})
click to toggle source
# File lib/aws/lex/conversation/type/base.rb, line 98 def property(attribute, opts = {}) from = opts.fetch(:from) do Support::Inflector.new(attribute).to_camel_case.to_sym end params = { from: from }.merge(opts) attr_accessor(attribute) if opts.fetch(:virtual) { false } virtual_attributes << attribute else mapping[attribute] = from end translate(attribute => params) end
required(attribute, opts = {})
click to toggle source
# File lib/aws/lex/conversation/type/base.rb, line 90 def required(attribute, opts = {}) property(attribute, opts.merge(allow_nil: false)) end
symbolize_hash!()
click to toggle source
# File lib/aws/lex/conversation/type/base.rb, line 70 def symbolize_hash! ->(v) { v.transform_keys(&:to_sym) } end
virtual_attributes()
click to toggle source
# File lib/aws/lex/conversation/type/base.rb, line 119 def virtual_attributes @virtual_attributes ||= [] end