scope_composer 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTUxOTViNDczMGU0MTRkYjEzNzUzNWVhZTkzNWNmYWYxYjAyNjZjZQ==
4
+ ODZmYzRjMTc3ZTg2ZGJiMjA0NWY4NjhhNzBiN2Q2MmNlOWNhNDBmOQ==
5
5
  data.tar.gz: !binary |-
6
- Yzg1NWNlZGRhM2I1YWZiM2ZiZWNkZDJiZmQ5ZTlmMmRiMThjZTkxNw==
6
+ NjZmZjFmZjFlNzNiNmVkYjFhZDJjYmVkNTY0ZDMxNTg5ZGMxNTIwOA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YmNmYzU5NDc0NzY5MTQxZmJlNTQ3Y2NlNTIyYmU2MzQ5OTFlNmIxYzdkMDI1
10
- MzEyZjdkZjE3MGVmMjFjNzJjMjExZTM4Yjg4Njg4MzgwYjRlNGEyNTkzNTg3
11
- N2I3Zjg1MjY1NmE2NWQwZGNiNTU1ZDg2OWQwOGU3ZDk0NmU4ZGU=
9
+ OGRlYWZhYjNlMDhjN2RhNDJjMWFlNWYzNTlkM2JmZDg2YTYxOWU4YjdjMmRl
10
+ NzA5MTIyYjY3OWY1ODc4ZDE0ZTZlM2NhOTM0MTY3Yjc2MmU1ZDE0Y2U4ZDU1
11
+ NmViNmViMWFlYjY5OTMyNGNiOTk0NDcyOGFjZjFmNjc2YTNkOGI=
12
12
  data.tar.gz: !binary |-
13
- NjdkOTBkYTRhZjcxZmM1ZDFhZGQ4MTlmMzEwMWZiZWY0NjU5Zjk4ODAzZjgz
14
- YzhjZDBlYWY4Y2I5YWE5Y2RmOGEyZmIyNzk3ZTA3MWFiMjIyMzIwMTUzYjA3
15
- ODVlNjAwMDc3NTAzMzY1OGFjMTE4NjVmMjkxZjBjYmY5ZjIxMzk=
13
+ ZDQ3MWRkZTdlMGJiYmMyYzVjOGUzZmJhMWE5M2MyY2ZhNGNmYzkzYzUzZmFk
14
+ YzUwNWQzYTcwNjYxM2Q5YTYzZmE4OGIzYzViODUzMzgyZmM1NTg3ZDVmNzlj
15
+ OWJhNmNkYTljZTRkNDQyN2Y3MjBhZTllYTZkMDVlYzFhZjc4ZTg=
@@ -149,6 +149,7 @@ class Scope
149
149
  end
150
150
 
151
151
  def write_scope_attribute(key, values)
152
+ values = Array(values)
152
153
  return unless values.compact.present?
153
154
  scope_attributes[key] = (values.count == 1) ? values.first : values
154
155
  end
@@ -1,3 +1,3 @@
1
1
  module ScopeComposer
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
@@ -8,12 +8,14 @@ describe ScopeComposer::Model do
8
8
 
9
9
  has_scope_composer
10
10
  scope :say_hi, ->(t){ scope_attributes[:say_hi] = t }
11
+
11
12
  scope_helper :helper_method, ->(t){ 'hi' }
12
13
 
13
14
  scope_composer_for :search
14
15
  search_scope :select
15
16
  search_scope :limit
16
17
  search_scope :offset, prefix: true
18
+ search_scope :value_to_i, ->(value){ scope_attributes[:value_to_i] = value.to_i }
17
19
  search_helper :tester, ->(t){ t.to_i }
18
20
 
19
21
  end
@@ -65,9 +67,9 @@ describe ScopeComposer::Model do
65
67
  its(:attributes){ should eq({ id: 20 }) }
66
68
  end
67
69
 
68
- describe "#scoped" do
70
+ describe "#clone" do
69
71
  before(:each){ scope.where( id: 20 ) }
70
- subject{ scope.scoped }
72
+ subject{ scope.clone }
71
73
 
72
74
  its(:attributes){ should eq({ id: 20 }) }
73
75
 
@@ -78,7 +80,16 @@ describe ScopeComposer::Model do
78
80
  subject.attributes.should eq({id: 40})
79
81
  end
80
82
 
81
-
83
+ end
84
+
85
+ describe "#limit=" do
86
+ before(:each){ subject.limit = 10 }
87
+ its(:limit){ should eq 10 }
88
+ end
89
+
90
+ describe "#value_to_i=" do
91
+ before(:each){ subject.value_to_i = '10' }
92
+ its(:value_to_i){ should eq 10 }
82
93
  end
83
94
 
84
95
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
2
 
3
+ require 'pry'
3
4
  require "rspec"
4
5
  require "scope_composer"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scope_composer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Hilscher