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

.allow_set?Boolean

Returns:

  • (Boolean)

175
176
177
# File 'lib/aws/record/attributes.rb', line 175

def self.allow_set?
  false
end

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


164
165
166
167
168
169
170
171
172
# File 'lib/aws/record/attributes.rb', line 164

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


155
156
157
158
159
160
161
162
# File 'lib/aws/record/attributes.rb', line 155

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