active_enumerable 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/CHANGELOG.md +2 -0
- data/README.md +24 -18
- data/active_enumerable.gemspec +3 -2
- data/lib/active_enumerable.rb +1 -6
- data/lib/active_enumerable/base.rb +16 -26
- data/lib/active_enumerable/english_dsl.rb +4 -2
- data/lib/active_enumerable/extract_options.rb +29 -0
- data/lib/active_enumerable/order.rb +48 -0
- data/lib/active_enumerable/queries.rb +20 -92
- data/lib/active_enumerable/scopes.rb +2 -6
- data/lib/active_enumerable/version.rb +1 -1
- data/lib/active_enumerable/where.rb +2 -0
- metadata +22 -6
- data/lib/active_enumerable/enumerable.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db5edb0e4e9f6d7f8fd5a300614a183963166077
|
4
|
+
data.tar.gz: e1b94fd1c797689656ba6191fdb9de1fe8ba6bfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c7f661c81d3ad8bc7a1c8cef010cd9dffb22bb668f7244b089352e9415216372b8fa522bb5afc1032e25779b7873bb7835217c02d972566fb9e05c2702f54a0
|
7
|
+
data.tar.gz: 93a46896255357f33867972e7a6335285908ec7dd76383028db39caf80ef88741d7955388aa8d44cd68a60012ea7b5bb53bee0eda0401290ea723913851a2c72
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
[![Build Status](https://travis-ci.org/zeisler/active_enumerable.svg?branch=master)](https://travis-ci.org/zeisler/active_enumerable)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/active_enumerable.svg)](https://badge.fury.io/rb/active_enumerable)
|
5
5
|
|
6
|
-
|
6
|
+
Provides ActiveRecord like query methods for use in Ruby Enumerable collections.
|
7
|
+
Use Hashes or custom Ruby Objects to represent records.
|
7
8
|
|
8
9
|
## Installation
|
9
10
|
|
@@ -30,33 +31,39 @@ require "active_enumerable"
|
|
30
31
|
|
31
32
|
class Customers
|
32
33
|
include ActiveEnumerable
|
33
|
-
|
34
|
+
|
34
35
|
scope :unpaid, -> { where(paid: false).or(credit: 0) }
|
35
36
|
end
|
36
37
|
|
37
38
|
customers = Customers.new([{paid: true, credit: 1000}, {paid: false, credit: 2000}, {paid: false, credit: 0}])
|
38
39
|
|
39
40
|
customers.unpaid
|
40
|
-
|
41
|
-
|
42
|
-
customers.scope { select { |y| y
|
43
|
-
|
44
|
-
|
41
|
+
# => <#Customers [{:paid=>false, :credit=>2000}, {:paid=>false, :credit=>0}]]>
|
42
|
+
|
43
|
+
customers.scope { select { |y| y[:credit] >= 1000 } }
|
44
|
+
#=> <#Customers [{paid: true, credit: 1000}, {paid: false, credit: 2000}]>
|
45
|
+
|
45
46
|
customers.sum(:credit)
|
46
|
-
|
47
|
-
|
48
|
-
customers.create({paid: true, credit: 1500}) # defaults to Hash creations
|
47
|
+
#=> 3000
|
49
48
|
|
50
|
-
|
49
|
+
customers << { paid: true, credit: 1500 } # accepts Hashes
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
class Customer
|
52
|
+
attr_reader :paid, :credit
|
53
|
+
def initialize(paid:, credit:)
|
54
|
+
@paid = paid
|
55
|
+
@credit = credit
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
customers << Customer.new(paid: true, credit: 1500) # Or Objects
|
55
60
|
```
|
56
61
|
|
57
62
|
### English Like DSL
|
58
63
|
|
59
64
|
```ruby
|
65
|
+
require "active_enumerable"
|
66
|
+
|
60
67
|
class People
|
61
68
|
include ActiveEnumerable
|
62
69
|
|
@@ -64,7 +71,7 @@ class People
|
|
64
71
|
end
|
65
72
|
|
66
73
|
people = People.new([{ name: "Reuben" }, { name: "Naomi" }])
|
67
|
-
people.where { has(:name).of("Reuben") }
|
74
|
+
people.where { has(:name).of("Reuben") }
|
68
75
|
#=> <#People [{ name: "Reuben" }]]
|
69
76
|
|
70
77
|
|
@@ -75,9 +82,6 @@ people = People.new( [
|
|
75
82
|
|
76
83
|
people.where { has(:parents).of(age: 29, name: "Mom").or(age: 33, name: "Dad") }
|
77
84
|
#=> <#People [{ name: "Reuben", parents: [...] }, { name: "Naomi", parents: [...] }]
|
78
|
-
|
79
|
-
people.where { has(:parents).of(age: 29, name: "Mom").and(age: 33, name: "Dad")
|
80
|
-
#=> <#People [{ name: "Reuben", parents: [...] }>
|
81
85
|
```
|
82
86
|
|
83
87
|
## Development
|
@@ -88,6 +92,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
88
92
|
|
89
93
|
## Contributing
|
90
94
|
|
95
|
+
This is a community project and commit access will be granted to those who show interest by having a history of acceptable pull-requests.
|
96
|
+
|
91
97
|
Bug reports and pull requests are welcome on GitHub at https://github.com/zeisler/active_enumerable. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
92
98
|
|
93
99
|
|
data/active_enumerable.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Dustin Zeisler"]
|
10
10
|
spec.email = ["dustin@zeisler.net"]
|
11
11
|
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.description = %q{
|
12
|
+
spec.summary = %q{Provides ActiveRecord like query methods for use in Ruby Enumerable collections.}
|
13
|
+
spec.description = %q{Provides ActiveRecord like query methods for use in Ruby Enumerable collections. Use Hashes or custom Ruby Objects to represent records.}
|
14
14
|
spec.homepage = "https://github.com/zeisler/active_enumerable"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.10"
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
26
|
spec.add_development_dependency "rspec", "~> 3.4"
|
27
|
+
spec.add_development_dependency "simplecov", "~> 0.15.1"
|
27
28
|
end
|
data/lib/active_enumerable.rb
CHANGED
@@ -2,7 +2,6 @@ require "active_enumerable/version"
|
|
2
2
|
require "active_enumerable/base"
|
3
3
|
require "active_enumerable/record_not_found"
|
4
4
|
require "active_enumerable/comparable"
|
5
|
-
require "active_enumerable/enumerable"
|
6
5
|
require "active_enumerable/finder"
|
7
6
|
require "active_enumerable/method_caller"
|
8
7
|
require "active_enumerable/scope_method"
|
@@ -19,11 +18,7 @@ module ActiveEnumerable
|
|
19
18
|
include Scopes
|
20
19
|
include EnglishDsl
|
21
20
|
|
22
|
-
module ClassMethods
|
23
|
-
include Scopes::ClassMethods
|
24
|
-
end
|
25
|
-
|
26
21
|
def self.included(base)
|
27
|
-
base.extend(ClassMethods)
|
22
|
+
base.extend(Scopes::ClassMethods)
|
28
23
|
end
|
29
24
|
end
|
@@ -1,6 +1,16 @@
|
|
1
1
|
module ActiveEnumerable
|
2
2
|
module Base
|
3
|
+
include ::Enumerable
|
4
|
+
|
5
|
+
def each(*args, &block)
|
6
|
+
@collection.send(:each, *args, &block)
|
7
|
+
end
|
8
|
+
|
3
9
|
def initialize(collection=[])
|
10
|
+
active_enumerable_setup(collection)
|
11
|
+
end
|
12
|
+
|
13
|
+
def active_enumerable_setup(collection=[])
|
4
14
|
if collection.is_a? ::Enumerator::Lazy
|
5
15
|
@collection = collection
|
6
16
|
else
|
@@ -12,23 +22,12 @@ module ActiveEnumerable
|
|
12
22
|
@collection.to_a
|
13
23
|
end
|
14
24
|
|
15
|
-
|
16
|
-
def __new_relation__(collection)
|
17
|
-
self.class.new(collection)
|
18
|
-
end
|
19
|
-
|
20
|
-
def create(attributes)
|
21
|
-
add(if (klass = self.class.item_class)
|
22
|
-
klass.new(attributes)
|
23
|
-
else
|
24
|
-
attributes
|
25
|
-
end)
|
26
|
-
end
|
27
|
-
|
28
|
-
def add(item)
|
25
|
+
def <<(item)
|
29
26
|
@collection << item
|
30
27
|
end
|
31
28
|
|
29
|
+
alias_method :add, :<<
|
30
|
+
|
32
31
|
def all
|
33
32
|
self.tap { to_a }
|
34
33
|
end
|
@@ -37,18 +36,9 @@ module ActiveEnumerable
|
|
37
36
|
self.class.name
|
38
37
|
end
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
def item_class=(klass)
|
46
|
-
@item_class = klass
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.included(base)
|
51
|
-
base.extend(ClassMethods)
|
39
|
+
# @private
|
40
|
+
def __new_relation__(collection)
|
41
|
+
self.class.new(collection)
|
52
42
|
end
|
53
43
|
end
|
54
44
|
end
|
@@ -3,6 +3,8 @@ module ActiveEnumerable
|
|
3
3
|
include ScopeMethod
|
4
4
|
include Where
|
5
5
|
|
6
|
+
UnmetCondition = Class.new(StandardError)
|
7
|
+
|
6
8
|
# @param [Hash]
|
7
9
|
# @yield takes block to evaluate English Dsl
|
8
10
|
# <ActiveEnumerable>#where{ has(:name).of("Dustin") }
|
@@ -26,7 +28,7 @@ module ActiveEnumerable
|
|
26
28
|
# Or this can by any value to compare the result from attr.
|
27
29
|
def of(matches)
|
28
30
|
if all_conditions.empty? || !(all_conditions.last.count == 1)
|
29
|
-
raise ".has(attr) must be call before calling #of."
|
31
|
+
raise UnmetCondition, ".has(attr) must be call before calling #of."
|
30
32
|
else
|
31
33
|
all_conditions.last << matches
|
32
34
|
self
|
@@ -37,7 +39,7 @@ module ActiveEnumerable
|
|
37
39
|
# @param [Hash, Object] matches is list of sub conditions or associations to query.
|
38
40
|
# Or this can by any value to compare the result from attr.
|
39
41
|
def or(matches)
|
40
|
-
raise ".has(attr).of(matches) must be call before calling #or(matches)." if all_conditions.empty? || !(all_conditions.last.count == 2)
|
42
|
+
raise UnmetCondition, ".has(attr).of(matches) must be call before calling #or(matches)." if all_conditions.empty? || !(all_conditions.last.count == 2)
|
41
43
|
evaluation_results << english_where
|
42
44
|
all_conditions.last[1] = matches
|
43
45
|
evaluation_results << english_where
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Hash
|
2
|
+
# By default, only instances of Hash itself are extractable.
|
3
|
+
# Subclasses of Hash may implement this method and return
|
4
|
+
# true to declare themselves as extractable. If a Hash
|
5
|
+
# is extractable, Array#extract_options! pops it from
|
6
|
+
# the Array when it is the last element of the Array.
|
7
|
+
def extractable_options?
|
8
|
+
instance_of?(Hash)
|
9
|
+
end
|
10
|
+
end unless Hash.respond_to?(:extractable_options?)
|
11
|
+
|
12
|
+
class Array
|
13
|
+
# Extracts options from a set of arguments. Removes and returns the last
|
14
|
+
# element in the array if it's a hash, otherwise returns a blank hash.
|
15
|
+
#
|
16
|
+
# def options(*args)
|
17
|
+
# args.extract_options!
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# options(1, 2) # => {}
|
21
|
+
# options(1, 2, a: :b) # => {:a=>:b}
|
22
|
+
def extract_options!
|
23
|
+
if last.is_a?(Hash) && last.extractable_options?
|
24
|
+
pop
|
25
|
+
else
|
26
|
+
{}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end unless Array.respond_to?(:extract_options!)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "active_enumerable/extract_options"
|
2
|
+
|
3
|
+
module ActiveEnumerable
|
4
|
+
# @private
|
5
|
+
module Order
|
6
|
+
class << self
|
7
|
+
def call(args, all)
|
8
|
+
options = args.extract_options!
|
9
|
+
if options.empty? && args.count == 1
|
10
|
+
all.sort_by { |item| MethodCaller.new(item).call(args.first) }
|
11
|
+
else
|
12
|
+
order_mixed_args(all, args, options)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def order_mixed_args(all, args, options)
|
19
|
+
normalized_opt = args.each_with_object({}) { |a, h| h[a] = :asc }.merge(options) # Add non specified direction keys
|
20
|
+
all.sort { |a, b| build_order(a, normalized_opt) <=> build_order(b, normalized_opt) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def build_order(a, options)
|
24
|
+
options.map { |k, v| send(v, MethodCaller.new(a).call(k)) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def desc(r)
|
28
|
+
DESC.new(r)
|
29
|
+
end
|
30
|
+
|
31
|
+
def asc(r)
|
32
|
+
r
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class DESC
|
37
|
+
attr_reader :r
|
38
|
+
|
39
|
+
def initialize(r)
|
40
|
+
@r = r
|
41
|
+
end
|
42
|
+
|
43
|
+
def <=>(other)
|
44
|
+
-(r <=> other.r) # Flip negative/positive result
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,7 +1,10 @@
|
|
1
|
+
require "active_enumerable/order"
|
2
|
+
require "bigdecimal"
|
3
|
+
|
1
4
|
module ActiveEnumerable
|
2
5
|
module Queries
|
3
|
-
|
4
|
-
#
|
6
|
+
# Find by id - Depends on either having an Object#id or Hash{id: Integer}
|
7
|
+
# This can either be a specific id (1), a list of ids (1, 5, 6), or an array of ids ([5, 6, 10]).
|
5
8
|
# If no record can be found for all of the listed ids, then RecordNotFound will be raised. If the primary key
|
6
9
|
# is an integer, find by id coerces its arguments using +to_i+.
|
7
10
|
#
|
@@ -14,7 +17,7 @@ module ActiveEnumerable
|
|
14
17
|
# @return [ActiveEnumerable, Object]
|
15
18
|
# @param [*Fixnum, Array<Fixnum>] args
|
16
19
|
def find(*args)
|
17
|
-
raise RecordNotFound.new("Couldn't find #{self.name} without an ID") if args.compact.empty?
|
20
|
+
raise RecordNotFound.new("Couldn't find #{self.respond_to?(:name) ? self.name : self.class.name} without an ID") if args.compact.empty?
|
18
21
|
if args.count > 1 || args.first.is_a?(Array)
|
19
22
|
__new_relation__(args.flatten.lazy.map do |id|
|
20
23
|
find_by!(id: id.to_i)
|
@@ -24,52 +27,6 @@ module ActiveEnumerable
|
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
27
|
-
# Updates all records with details given if they match a set of conditions supplied, limits and order can
|
28
|
-
# also be supplied.
|
29
|
-
#
|
30
|
-
# ==== Parameters
|
31
|
-
#
|
32
|
-
# * +updates+ - A string, array, or hash.
|
33
|
-
#
|
34
|
-
# ==== Examples
|
35
|
-
#
|
36
|
-
# # Update all customers with the given attributes
|
37
|
-
# <#ActiveEnumerable>.update_all wants_email: true
|
38
|
-
#
|
39
|
-
# # Update all books with 'Rails' in their title
|
40
|
-
# <#ActiveEnumerable>.where(title: 'Rails').update_all(author: 'David')
|
41
|
-
#
|
42
|
-
# # Update all books that match conditions, but limit it to 5 ordered by date
|
43
|
-
# <#ActiveEnumerable>.where(title: 'Rails').order(:created_at).limit(5).update_all(author: 'David')
|
44
|
-
def update_all(attributes)
|
45
|
-
all.each { |i| i.update(attributes) }
|
46
|
-
end
|
47
|
-
|
48
|
-
# Updates an object (or multiple objects) and saves it.
|
49
|
-
#
|
50
|
-
# ==== Parameters
|
51
|
-
#
|
52
|
-
# * +id+ - This should be the id or an array of ids to be updated.
|
53
|
-
# * +attributes+ - This should be a hash of attributes or an array of hashes.
|
54
|
-
#
|
55
|
-
# ==== Examples
|
56
|
-
#
|
57
|
-
# # Updates one record
|
58
|
-
# <#ActiveEnumerable>.update(15, user_name: 'Samuel', group: 'expert')
|
59
|
-
#
|
60
|
-
# # Updates multiple records
|
61
|
-
# people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy" } }
|
62
|
-
# <#ActiveEnumerable>.update(people.keys, people.values)
|
63
|
-
def update(id, attributes)
|
64
|
-
if id.is_a?(Array)
|
65
|
-
id.map.with_index { |one_id, idx| update(one_id, attributes[idx]) }
|
66
|
-
else
|
67
|
-
object = find(id)
|
68
|
-
object.update(attributes)
|
69
|
-
object
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
30
|
# Finds the first record matching the specified conditions. There
|
74
31
|
# is no implied ordering so if order matters, you should specify it
|
75
32
|
# yourself.
|
@@ -95,39 +52,6 @@ module ActiveEnumerable
|
|
95
52
|
result
|
96
53
|
end
|
97
54
|
|
98
|
-
# Finds the first record with the given attributes, or creates a record
|
99
|
-
# with the attributes if one is not found:
|
100
|
-
#
|
101
|
-
# # Find the first user named "Penélope" or create a new one.
|
102
|
-
# <#ActiveEnumerable>.find_or_create_by(first_name: 'Penélope')
|
103
|
-
# # => #<User id: 1, first_name: "Penélope", last_name: nil>
|
104
|
-
#
|
105
|
-
# # Find the first user named "Penélope" or create a new one.
|
106
|
-
# # We already have one so the existing record will be returned.
|
107
|
-
# <#ActiveEnumerable>.find_or_create_by(first_name: 'Penélope')
|
108
|
-
# # => #<User id: 1, first_name: "Penélope", last_name: nil>
|
109
|
-
#
|
110
|
-
# This method accepts a block, which is passed down to +create+. The last example
|
111
|
-
# above can be alternatively written this way:
|
112
|
-
#
|
113
|
-
# # Find the first user named "Scarlett" or create a new one with a
|
114
|
-
# # different last name.
|
115
|
-
# <#ActiveEnumerable>.find_or_create_by(first_name: 'Scarlett') do |user|
|
116
|
-
# user.last_name = 'Johansson'
|
117
|
-
# end
|
118
|
-
# # => #<User id: 2, first_name: "Scarlett", last_name: "Johansson">
|
119
|
-
#
|
120
|
-
def find_or_create_by(attributes, &block)
|
121
|
-
find_by(attributes) || create(attributes, &block)
|
122
|
-
end
|
123
|
-
|
124
|
-
alias_method :find_or_create_by!, :find_or_create_by
|
125
|
-
|
126
|
-
# Like <tt>find_or_create_by</tt>, but calls <tt>new</tt> instead of <tt>create</tt>.
|
127
|
-
def find_or_initialize_by(attributes, &block)
|
128
|
-
find_by(attributes) || new(attributes, &block)
|
129
|
-
end
|
130
|
-
|
131
55
|
# Count the records.
|
132
56
|
#
|
133
57
|
# <#ActiveEnumerable>.count
|
@@ -136,17 +60,15 @@ module ActiveEnumerable
|
|
136
60
|
# <#ActiveEnumerable>.count(:age)
|
137
61
|
# # => returns the total count of all people whose age is not nil
|
138
62
|
def count(name = nil)
|
139
|
-
return
|
140
|
-
|
63
|
+
return to_a.size if name.nil?
|
64
|
+
to_a.reject { |record| Finder.new(record).is_of(name: nil) }.size
|
141
65
|
end
|
142
66
|
|
143
67
|
# Specifies a limit for the number of records to retrieve.
|
144
68
|
#
|
145
69
|
# <#ActiveEnumerable>.limit(10)
|
146
70
|
def limit(num)
|
147
|
-
|
148
|
-
relation.send(:set_from_limit)
|
149
|
-
relation
|
71
|
+
__new_relation__(all.take(num))
|
150
72
|
end
|
151
73
|
|
152
74
|
# Calculates the sum of values on a given attribute. The value is returned
|
@@ -167,11 +89,12 @@ module ActiveEnumerable
|
|
167
89
|
def average(key)
|
168
90
|
values = values_by_key(key)
|
169
91
|
total = values.inject { |sum, n| sum + n }
|
92
|
+
return unless total
|
170
93
|
BigDecimal.new(total) / BigDecimal.new(values.count)
|
171
94
|
end
|
172
95
|
|
173
|
-
# Calculates the minimum value on a given attribute.
|
174
|
-
#
|
96
|
+
# Calculates the minimum value on a given attribute. Returns +nil+ if there's
|
97
|
+
# no row.
|
175
98
|
#
|
176
99
|
# <#ActiveEnumerable>.minimum(:age) # => 7
|
177
100
|
def minimum(key)
|
@@ -191,10 +114,15 @@ module ActiveEnumerable
|
|
191
114
|
# <#ActiveEnumerable>.order('name')
|
192
115
|
#
|
193
116
|
# <#ActiveEnumerable>.order(:name)
|
194
|
-
|
195
|
-
|
117
|
+
#
|
118
|
+
# <#ActiveEnumerable>.order(email: :desc)
|
119
|
+
#
|
120
|
+
# <#ActiveEnumerable>.order(:name, email: :desc)
|
121
|
+
def order(*args)
|
122
|
+
__new_relation__(Order.call(args, all))
|
196
123
|
end
|
197
124
|
|
125
|
+
|
198
126
|
# Reverse the existing order clause on the relation.
|
199
127
|
#
|
200
128
|
# <#ActiveEnumerable>.order('name').reverse_order
|
@@ -233,7 +161,7 @@ module ActiveEnumerable
|
|
233
161
|
private
|
234
162
|
|
235
163
|
def values_by_key(key)
|
236
|
-
all.map { |obj| obj.
|
164
|
+
all.map { |obj| MethodCaller.new(obj).call(key) }
|
237
165
|
end
|
238
166
|
end
|
239
167
|
end
|
@@ -9,12 +9,8 @@ module ActiveEnumerable
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
def respond_to_missing?(meth,
|
13
|
-
|
14
|
-
true
|
15
|
-
else
|
16
|
-
super
|
17
|
-
end
|
12
|
+
def respond_to_missing?(meth, _include_private = false)
|
13
|
+
create_scope_method(meth)
|
18
14
|
end
|
19
15
|
|
20
16
|
def create_scope_method(meth)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_enumerable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Zeisler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,7 +52,22 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.4'
|
55
|
-
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.15.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.15.1
|
69
|
+
description: Provides ActiveRecord like query methods for use in Ruby Enumerable collections.
|
70
|
+
Use Hashes or custom Ruby Objects to represent records.
|
56
71
|
email:
|
57
72
|
- dustin@zeisler.net
|
58
73
|
executables: []
|
@@ -75,9 +90,10 @@ files:
|
|
75
90
|
- lib/active_enumerable/base.rb
|
76
91
|
- lib/active_enumerable/comparable.rb
|
77
92
|
- lib/active_enumerable/english_dsl.rb
|
78
|
-
- lib/active_enumerable/
|
93
|
+
- lib/active_enumerable/extract_options.rb
|
79
94
|
- lib/active_enumerable/finder.rb
|
80
95
|
- lib/active_enumerable/method_caller.rb
|
96
|
+
- lib/active_enumerable/order.rb
|
81
97
|
- lib/active_enumerable/queries.rb
|
82
98
|
- lib/active_enumerable/record_not_found.rb
|
83
99
|
- lib/active_enumerable/scope_method.rb
|
@@ -104,8 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
120
|
version: '0'
|
105
121
|
requirements: []
|
106
122
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.6.14
|
108
124
|
signing_key:
|
109
125
|
specification_version: 4
|
110
|
-
summary:
|
126
|
+
summary: Provides ActiveRecord like query methods for use in Ruby Enumerable collections.
|
111
127
|
test_files: []
|