activerecord-devkit 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -51,6 +51,8 @@ new_role = user.roles.build
51
51
  new_role = user.roles.soft_build
52
52
  # or
53
53
  new_role = user.association(:roles).soft_build
54
+ # or
55
+ new_role = user.roles.where(name: 'admin').soft_build
54
56
  ```
55
57
 
56
58
  ## License
@@ -1,6 +1,12 @@
1
1
  RubyFeatures.define 'activerecord_devkit/association_soft_build' do
2
2
  condition(:activerecord_3){ ActiveRecord::VERSION::MAJOR == 3 }
3
3
 
4
+ apply_to 'ActiveRecord::Relation' do
5
+ applied do
6
+ alias soft_build build
7
+ end
8
+ end
9
+
4
10
  apply_to 'ActiveRecord::Associations::CollectionProxy' do
5
11
  applied do
6
12
  delegate :soft_build, to: :@association
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordDevkit
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
@@ -32,4 +32,9 @@ describe 'association_soft_build' do
32
32
  expect(subject.roles).to be_empty
33
33
  end
34
34
 
35
+ it 'should build relation' do
36
+ role = Role.where(user_id: 10).soft_build
37
+ expect(role.user_id).to eq(10)
38
+ end
39
+
35
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-devkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-24 00:00:00.000000000 Z
12
+ date: 2015-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-features