You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.
Class: AWS::Record::Attributes::BaseAttr
- Inherits:
 - 
      Object
      
        
- Object
 - AWS::Record::Attributes::BaseAttr
 
 
- Defined in:
 - lib/aws/record/attributes.rb
 
Overview
Base class for all of the AWS::Record attributes.
Direct Known Subclasses
BooleanAttr, DateAttr, DateTimeAttr, FloatAttr, IntegerAttr, StringAttr
Instance Attribute Summary collapse
- 
  
    
      #name  ⇒ String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The name of this attribute.
 - 
  
    
      #options  ⇒ Hash 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Attribute options passed to the constructor.
 
Class Method Summary collapse
- 
  
    
      .allow_set?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Returns true if this attribute type can be used with the
:set => trueoption. - 
  
    
      .deserialize(serialized_value, options = {})  ⇒ Mixed 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the type-casted deserialized value.
 
Instance Method Summary collapse
- 
  
    
      #default_value  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the default value for this attribute.
 - 
  
    
      #deserialize(serialized_value)  ⇒ Mixed 
    
    
  
  
  
  
  
  
  
  
  
    
Returns a deserialized type-casted value.
 - 
  
    
      #initialize(name, options = {})  ⇒ BaseAttr 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of BaseAttr.
 - 
  
    
      #persist_as  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the name this attribute will use in the storage backend.
 - 
  
    
      #serialize(type_casted_value)  ⇒ Mixed 
    
    
  
  
  
  
  
  
  
  
  
    
Takes the type casted value and serializes it.
 - 
  
    
      #set?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Returns true if this attribute can have multiple values.
 - 
  
    
      #type_cast(raw_value)  ⇒ Mixed 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the type casted value.
 
Constructor Details
#initialize(name, options = {}) ⇒ BaseAttr
Returns a new instance of BaseAttr
      31 32 33 34 35 36 37  | 
    
      # File 'lib/aws/record/attributes.rb', line 31 def initialize name, = {} @name = name.to_s @options = .dup if [:set] and !self.class.allow_set? raise ArgumentError, "invalid option :set for #{self.class}" end end  | 
  
Instance Attribute Details
#name ⇒ String (readonly)
Returns The name of this attribute
      40 41 42  | 
    
      # File 'lib/aws/record/attributes.rb', line 40 def name @name end  | 
  
#options ⇒ Hash (readonly)
Returns Attribute options passed to the constructor.
      43 44 45  | 
    
      # File 'lib/aws/record/attributes.rb', line 43 def @options end  | 
  
Class Method Details
.allow_set? ⇒ Boolean
Returns true if this attribute type can be used
with the :set => true option.  Certain attirbutes can not
be represented with multiple values (like BooleanAttr).
      94 95 96  | 
    
      # File 'lib/aws/record/attributes.rb', line 94 def self.allow_set? raise NotImplementedError end  | 
  
.deserialize(serialized_value, options = {}) ⇒ Mixed
Returns the type-casted deserialized value.
      87 88 89  | 
    
      # File 'lib/aws/record/attributes.rb', line 87 def self.deserialize serialized_value, = {} self.type_cast(serialized_value, ) end  | 
  
Instance Method Details
#default_value ⇒ Object
Returns the default value for this attribute.
      52 53 54 55 56 57 58  | 
    
      # File 'lib/aws/record/attributes.rb', line 52 def default_value if [:default_value].is_a?(Proc) [:default_value].call else [:default_value] end end  | 
  
#deserialize(serialized_value) ⇒ Mixed
Returns a deserialized type-casted value.
      74 75 76  | 
    
      # File 'lib/aws/record/attributes.rb', line 74 def deserialize serialized_value self.class.deserialize(serialized_value, ) end  | 
  
#persist_as ⇒ String
Returns the name this attribute will use in the storage backend.
      62 63 64  | 
    
      # File 'lib/aws/record/attributes.rb', line 62 def persist_as ([:persist_as] || @name).to_s end  | 
  
#serialize(type_casted_value) ⇒ Mixed
Takes the type casted value and serializes it
      81 82 83  | 
    
      # File 'lib/aws/record/attributes.rb', line 81 def serialize type_casted_value self.class.serialize(type_casted_value, ) end  | 
  
#set? ⇒ Boolean
Returns true if this attribute can have multiple values.
      47 48 49  | 
    
      # File 'lib/aws/record/attributes.rb', line 47 def set? [:set] ? true : false end  | 
  
#type_cast(raw_value) ⇒ Mixed
Returns the type casted value.
      68 69 70  | 
    
      # File 'lib/aws/record/attributes.rb', line 68 def type_cast raw_value self.class.type_cast(raw_value, ) end  |