You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: AWS::Record::Attributes::BooleanAttr

Inherits:
BaseAttr
  • Object
show all
Defined in:
lib/aws/record/attributes.rb

Direct Known Subclasses

Model::Attributes::BooleanAttr

Instance Attribute Summary

Attributes inherited from BaseAttr

#name, #options

Class Method Summary collapse

Methods inherited from BaseAttr

#default_value, #deserialize, deserialize, #initialize, #persist_as, #serialize, #set?, #type_cast

Constructor Details

This class inherits a constructor from AWS::Record::Attributes::BaseAttr

Class Method Details

.serialize(boolean, options = {}) ⇒ Object



168
169
170
171
172
173
174
175
176
# File 'lib/aws/record/attributes.rb', line 168

def self.serialize boolean, options = {}
  case boolean
  when false then 0
  when true  then 1
  else
    msg = "expected a boolean value, got #{boolean.class}"
    raise ArgumentError, msg
  end
end

.type_cast(raw_value, options = {}) ⇒ Object



159
160
161
162
163
164
165
166
# File 'lib/aws/record/attributes.rb', line 159

def self.type_cast raw_value, options = {}
  case raw_value
  when nil then nil
  when '' then nil
  when false, 'false', '0', 0 then false
  else true
  end
end