activerecord_to_poro 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/README.md +18 -0
 - data/lib/activerecord_to_poro/object_mapper.rb +2 -0
 - data/lib/activerecord_to_poro/version.rb +1 -1
 - data/spec/integration/lib/activerecord_to_poro/metadata_enabled_ar_spec.rb +1 -1
 - data/spec/integration/lib/activerecord_to_poro/object_mapper_spec.rb +24 -1
 - 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: 8dd9ccad82ce27decc321a3ecc0e46ee03ae03a2
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: e5efe27480922d9306c038d098ef6d76872507c2
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: dcdc20ef41bea88a23bc9066e1e5a767494af88d8313990e7bc577a7b8107c03528b7fbdf93c497e90d7f30390b0fa99c12a7b4c3b8cda3712098cb674519344
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: e9ff0ac70f6b78a0ebe6c77545a0fe87b34fd6bea9a60e99c627543c87236235ae278a6825b1bb16b39b2118b7f417d4974e31f594ab55908d27c6947322e45c
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -95,8 +95,26 @@ roles_converter.extend_mapping do 
     | 
|
| 
       95 
95 
     | 
    
         
             
            end
         
     | 
| 
       96 
96 
     | 
    
         | 
| 
       97 
97 
     | 
    
         | 
| 
      
 98 
     | 
    
         
            +
            # Enable loading AciveRecord Objects from a cache, when the data for 
         
     | 
| 
      
 99 
     | 
    
         
            +
            # saving is needed
         
     | 
| 
       98 
100 
     | 
    
         | 
| 
       99 
101 
     | 
    
         | 
| 
      
 102 
     | 
    
         
            +
            class Salutation < ActiveRecord::Base
         
     | 
| 
      
 103 
     | 
    
         
            +
              has_many :users, autosave: true
         
     | 
| 
      
 104 
     | 
    
         
            +
              
         
     | 
| 
      
 105 
     | 
    
         
            +
              after_find :add_to_cache
         
     | 
| 
      
 106 
     | 
    
         
            +
              
         
     | 
| 
      
 107 
     | 
    
         
            +
              def self.query_from_cache(query_attrs)        
         
     | 
| 
      
 108 
     | 
    
         
            +
                found_obj = # find by primary key & lock_version from cache
         
     | 
| 
      
 109 
     | 
    
         
            +
              end
         
     | 
| 
      
 110 
     | 
    
         
            +
              
         
     | 
| 
      
 111 
     | 
    
         
            +
              
         
     | 
| 
      
 112 
     | 
    
         
            +
               def add_to_cache
         
     | 
| 
      
 113 
     | 
    
         
            +
                 # add self to a cache
         
     | 
| 
      
 114 
     | 
    
         
            +
                 true
         
     | 
| 
      
 115 
     | 
    
         
            +
               end
         
     | 
| 
      
 116 
     | 
    
         
            +
            end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
       100 
118 
     | 
    
         | 
| 
       101 
119 
     | 
    
         
             
            ```
         
     | 
| 
       102 
120 
     | 
    
         | 
| 
         @@ -39,7 +39,8 @@ describe ActiverecordToPoro::ObjectMapper do 
     | 
|
| 
       39 
39 
     | 
    
         | 
| 
       40 
40 
     | 
    
         
             
              context 'instance methods' do
         
     | 
| 
       41 
41 
     | 
    
         
             
                subject!{
         
     | 
| 
       42 
     | 
    
         
            -
                  ActiverecordToPoro::ObjectMapper.create(User,  convert_associations: {roles: roles_converter, 
     | 
| 
      
 42 
     | 
    
         
            +
                  ActiverecordToPoro::ObjectMapper.create(User,  convert_associations: {roles: roles_converter,
         
     | 
| 
      
 43 
     | 
    
         
            +
                                                                                        salutation: salutation_converter})
         
     | 
| 
       43 
44 
     | 
    
         
             
                }
         
     | 
| 
       44 
45 
     | 
    
         | 
| 
       45 
46 
     | 
    
         
             
                let(:roles_converter){
         
     | 
| 
         @@ -84,6 +85,27 @@ describe ActiverecordToPoro::ObjectMapper do 
     | 
|
| 
       84 
85 
     | 
    
         
             
                    expect(subject.load(ar_object, poro_to_fill).object_id).to eq poro_to_fill.object_id
         
     | 
| 
       85 
86 
     | 
    
         
             
                  end
         
     | 
| 
       86 
87 
     | 
    
         | 
| 
      
 88 
     | 
    
         
            +
                  it 'resets changes flag if a method is given, mass assignment not used and no prefilled object given' do
         
     | 
| 
      
 89 
     | 
    
         
            +
                    result_class = Struct.new(:id) do
         
     | 
| 
      
 90 
     | 
    
         
            +
                      def reset_changes_flag
         
     | 
| 
      
 91 
     | 
    
         
            +
                        @reset_changes = :called
         
     | 
| 
      
 92 
     | 
    
         
            +
                      end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                      def reset_changes
         
     | 
| 
      
 95 
     | 
    
         
            +
                        @reset_changes ||= :not_called
         
     | 
| 
      
 96 
     | 
    
         
            +
                      end
         
     | 
| 
      
 97 
     | 
    
         
            +
                    end
         
     | 
| 
      
 98 
     | 
    
         
            +
                    mapper = ActiverecordToPoro::ObjectMapper.create(User,
         
     | 
| 
      
 99 
     | 
    
         
            +
                                                                     load_source: result_class,
         
     | 
| 
      
 100 
     | 
    
         
            +
                                                                     only: :id,
         
     | 
| 
      
 101 
     | 
    
         
            +
                                                                     use_mass_assignment_constructor: false)
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                    poro = mapper.load(ar_object)
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                    expect(poro.reset_changes).to eq :called
         
     | 
| 
      
 107 
     | 
    
         
            +
                  end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
       87 
109 
     | 
    
         
             
                end
         
     | 
| 
       88 
110 
     | 
    
         | 
| 
       89 
111 
     | 
    
         
             
                describe '#dump' do
         
     | 
| 
         @@ -105,6 +127,7 @@ describe ActiverecordToPoro::ObjectMapper do 
     | 
|
| 
       105 
127 
     | 
    
         
             
                    new_ar_object = User.new
         
     | 
| 
       106 
128 
     | 
    
         
             
                    expect(subject.dump(loaded_poro_object, new_ar_object).object_id).to eq new_ar_object.object_id
         
     | 
| 
       107 
129 
     | 
    
         
             
                  end
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
       108 
131 
     | 
    
         
             
                end
         
     | 
| 
       109 
132 
     | 
    
         | 
| 
       110 
133 
     | 
    
         
             
              end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: activerecord_to_poro
         
     | 
| 
       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 
     | 
    
         
             
            - Dieter Späth
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2014-07- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-07-18 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: abstract_type
         
     |