active_tools 0.0.18 → 0.0.19
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a451df478d8f39ad55cc1a11c7865e664563d99
|
4
|
+
data.tar.gz: 98887658ee80c51ee04d95f690cd2b1d0bed869e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c5cb6ddf55fa0cc3b3a799b6fe41f33a488105c4a82ea46cbf51b1def9578e2a28d99b840ab98735144ad75855f6cf8de2bbab9db823d3ce9f2336fe81dece6
|
7
|
+
data.tar.gz: b280359750ec5da5f8daa76d7f3be199a80a4accbb77e28f68f59b08b2b5e893182bcf480d3aa34919bd2fda7c4345f6bbec559085d62dce96005d473c5467ab
|
@@ -19,7 +19,7 @@ module ActiveTools
|
|
19
19
|
outer_values = {}
|
20
20
|
where_values = {}
|
21
21
|
path.each do |assoc_name, remote_attributes|
|
22
|
-
reflection = reflections[assoc_name]
|
22
|
+
reflection = reflections.with_indifferent_access[assoc_name]
|
23
23
|
target = instance.try(reflection.name)
|
24
24
|
outer_values[reflection.name] = {}
|
25
25
|
Array(remote_attributes).each do |remote_attribute|
|
@@ -48,7 +48,7 @@ module ActiveTools
|
|
48
48
|
def adaptive_belongs_to(*args)
|
49
49
|
options = args.extract_options!
|
50
50
|
assoc_name = args.first
|
51
|
-
unless reflection = reflections[assoc_name]
|
51
|
+
unless reflection = reflections.with_indifferent_access[assoc_name]
|
52
52
|
raise(ArgumentError, ":#{assoc_name} method doesn't look like an association accessor!")
|
53
53
|
end
|
54
54
|
adapter_name = "#{assoc_name}_adaptive"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ActiveTools
|
2
|
+
module ActiveRecord
|
3
|
+
module FilterAssign
|
4
|
+
extend ::ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def filter_assign(*args)
|
11
|
+
options = args.extract_options!
|
12
|
+
args.each do |attribute|
|
13
|
+
define_method "#{attribute}=" do |value|
|
14
|
+
if (options[:if].nil? || (options[:if].is_a?(Proc) && options[:if].call(value) == true)) && (options[:unless].nil? || (options[:unless].is_a?(Proc) && options[:unless].call(value) == false))
|
15
|
+
if options.has_key?(:force_value)
|
16
|
+
super(options[:force_value])
|
17
|
+
end
|
18
|
+
else
|
19
|
+
super(value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
module OnLoadActiveRecord
|
30
|
+
include ActiveRecord::FilterAssign
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -3,6 +3,7 @@ require 'active_tools/active_record/adaptive_belongs_to'
|
|
3
3
|
require 'active_tools/active_record/custom_counter_cache'
|
4
4
|
require 'active_tools/active_record/with_permalink'
|
5
5
|
require 'active_tools/active_record/polymorphic_conditions'
|
6
|
+
require 'active_tools/active_record/filter_assign'
|
6
7
|
|
7
8
|
module ActiveTools
|
8
9
|
module ActiveRecord
|
data/lib/active_tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valery Kvon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -74,6 +74,7 @@ files:
|
|
74
74
|
- lib/active_tools/active_record/adaptive_belongs_to/adapter.rb
|
75
75
|
- lib/active_tools/active_record/custom_counter_cache.rb
|
76
76
|
- lib/active_tools/active_record/custom_counter_cache/instance_methods.rb
|
77
|
+
- lib/active_tools/active_record/filter_assign.rb
|
77
78
|
- lib/active_tools/active_record/polymorphic_conditions.rb
|
78
79
|
- lib/active_tools/active_record/record_id.rb
|
79
80
|
- lib/active_tools/active_record/with_permalink.rb
|
@@ -124,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
125
|
version: '0'
|
125
126
|
requirements: []
|
126
127
|
rubyforge_project: active_tools
|
127
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.4.3
|
128
129
|
signing_key:
|
129
130
|
specification_version: 4
|
130
131
|
summary: ActionDispatch, ActionController, ActiveModel, ActiveRecord, ActiveSupport,
|