activerecord_to_poro 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9dc5c0d0816f712505c234d34541043b596d901
4
- data.tar.gz: 4b63198258eef3a39ddef742cad138190746c18e
3
+ metadata.gz: 8dd9ccad82ce27decc321a3ecc0e46ee03ae03a2
4
+ data.tar.gz: e5efe27480922d9306c038d098ef6d76872507c2
5
5
  SHA512:
6
- metadata.gz: b4a6489f8984bf31cbdcf37073920f8d7dc7280e4c06248dfc80a943f87ae8cb6ebca579076feb48662ad42ce2791fe39b7b56609cd2514c6bbe81c055895200
7
- data.tar.gz: 2127a7d11692dbff1d684dfe00cd9586634ac031ca02f164318dcf53e9555f6affb9eaf9b06d7772ce968cee9359e22c90c890327f0184fd2dbce8da57848dbc
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
 
@@ -79,6 +79,8 @@ module ActiverecordToPoro
79
79
  attrs.each_pair do |key, value|
80
80
  entity.public_send "#{key}=", value
81
81
  end
82
+
83
+ entity.reset_changes_flag if entity.respond_to? :reset_changes_flag
82
84
  end
83
85
  }
84
86
  end
@@ -1,3 +1,3 @@
1
1
  module ActiverecordToPoro
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -2,7 +2,7 @@ require 'integration_spec_helper'
2
2
 
3
3
  describe ActiverecordToPoro::MetadataEnabledAr do
4
4
  subject{
5
- User.extend ActiverecordToPoro::MetadataEnabledAr
5
+ User.send(:include, ActiverecordToPoro::MetadataEnabledAr)
6
6
  User
7
7
  }
8
8
 
@@ -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, salutation: salutation_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.7
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-03 00:00:00.000000000 Z
11
+ date: 2014-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: abstract_type