denormalizer 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/denormalizer.gemspec +2 -2
- data/lib/denormalizer/denormalize.rb +3 -3
- data/spec/dummy/app/models/book.rb +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/denormalizer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "denormalizer"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jeremiah Hemphill"]
|
12
|
-
s.date = "2013-08-
|
12
|
+
s.date = "2013-08-08"
|
13
13
|
s.description = "Cache method outputs and automatically create chainable scopes based on their outputs"
|
14
14
|
s.email = "jeremiah@cloudspace.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -37,9 +37,9 @@ module Denormalizer
|
|
37
37
|
#
|
38
38
|
# Table aliases have been added so that denormalized scopes can be chained (JH 12-3-2012)
|
39
39
|
# Note that you can chain a method with it's false version
|
40
|
-
args.
|
40
|
+
args.each_with_index do |method_name, i|
|
41
41
|
# table_name is called on the model of the mixin
|
42
|
-
table_alias = "dnmos_#{table_name}_#{
|
42
|
+
table_alias = "dnmos_#{table_name}_#{i}"
|
43
43
|
# setup true scope
|
44
44
|
true_attributes = {
|
45
45
|
"#{table_alias}.denormalized_object_method" => method_name.to_s,
|
@@ -55,7 +55,7 @@ module Denormalizer
|
|
55
55
|
"#{table_alias}.method_output" => Denormalizer::MethodOutput::FalseOutput
|
56
56
|
}
|
57
57
|
false_scope_name = "denormalized_not_#{method_name.to_s.gsub('?', '')}".pluralize.to_sym
|
58
|
-
scope false_scope_name, lambda { joins("INNER JOIN denormalizer_method_outputs AS #{table_alias} on #{table_alias}.denormalized_object_type='#{
|
58
|
+
scope false_scope_name, lambda { joins("INNER JOIN denormalizer_method_outputs AS #{table_alias} on #{table_alias}.denormalized_object_type='#{denormalization_class}' AND #{table_alias}.denormalized_object_id=#{table_name}.id").where(false_attributes)}
|
59
59
|
|
60
60
|
instance_method_name = "denormalized_#{method_name.to_s}"
|
61
61
|
define_method instance_method_name do
|
@@ -6,7 +6,7 @@ class Book < ActiveRecord::Base
|
|
6
6
|
def short_name?
|
7
7
|
name.length < 5
|
8
8
|
end
|
9
|
-
denormalize [:short_name?, :printed?], :class_name => "different
|
9
|
+
denormalize [:short_name?, :printed?], :class_name => "different class name"
|
10
10
|
|
11
11
|
def printed?
|
12
12
|
!printings.empty?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: denormalizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
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: 2013-08-
|
12
|
+
date: 2013-08-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -257,7 +257,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
257
257
|
version: '0'
|
258
258
|
segments:
|
259
259
|
- 0
|
260
|
-
hash: -
|
260
|
+
hash: -1780767345382437700
|
261
261
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
262
262
|
none: false
|
263
263
|
requirements:
|