dynamo_record 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/dynamo_record/document.rb +5 -0
- data/lib/dynamo_record/version.rb +1 -1
- data/spec/dynamo_record/fields_spec.rb +10 -0
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a496ab94797e0112018c905936d04e042dead0a1
         | 
| 4 | 
            +
              data.tar.gz: d34840c6422fd7bbd249e5e1004b2fbb7619ed72
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a67f699ce593ca14db62a83e9c006eb5f462b914f0639cf61c898b593db6b6f4e43591f40b7b7681e6960c9a437c9302188d5911bc62495a2460e1a0fc734d96
         | 
| 7 | 
            +
              data.tar.gz: 07b96b1f71c8c3713a2cde8260050a1dd58f2fbb1319b5214e984c6b298355d09bb6f02f2b6394d56296d0b1cab5877b9e38332bd43e121fb64f5316027da7af
         | 
| @@ -23,6 +23,11 @@ module DynamoRecord | |
| 23 23 | 
             
                  @new_record = true
         | 
| 24 24 | 
             
                  @attributes = {}
         | 
| 25 25 |  | 
| 26 | 
            +
                  # Set default
         | 
| 27 | 
            +
                  self.class.attributes.each do |key, value|
         | 
| 28 | 
            +
                    send("#{key}=", value[:options][:default]) if value[:options][:default]
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
             | 
| 26 31 | 
             
                  attrs.each do |key, value|
         | 
| 27 32 | 
             
                    send("#{key}=", value)
         | 
| 28 33 | 
             
                  end
         | 
| @@ -30,6 +30,16 @@ RSpec.describe DynamoRecord::Fields do | |
| 30 30 | 
             
                                               name: {type: :string, options: {index: true}}})
         | 
| 31 31 | 
             
              end
         | 
| 32 32 |  | 
| 33 | 
            +
              it 'accepts default value' do
         | 
| 34 | 
            +
                class City
         | 
| 35 | 
            +
                  include DynamoRecord::Document
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  field :population, :integer, default: 0
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                expect(City.new.population).to eq(0)
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
             | 
| 33 43 | 
             
              it 'initializes with field values' do
         | 
| 34 44 | 
             
                person = Person.new(name: 'A person')
         | 
| 35 45 | 
             
                expect(person.name).to eq('A person')
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: dynamo_record
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.8
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Nguyen Vu Nguyen
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015-01- | 
| 11 | 
            +
            date: 2015-01-06 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         |