baza_models 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/VERSION +1 -1
- data/baza_models.gemspec +3 -3
- data/lib/baza_models/model.rb +7 -4
- data/spec/baza_models/query_spec.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 559ac4422c97943f4d90db128a3ee939b7d81b5f
|
4
|
+
data.tar.gz: 1e5d6e48878a1375650a6775d9e2183bcb2b53d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97b3c4a05c69c616b7ba4eec678b1580a5cc9897bda2063c345f5245fa6340911b3b45558b0072b09b6c4c6ab1d7cba9ae8fe6bac6d283eea2e6cd3eb4341424
|
7
|
+
data.tar.gz: 640af41b9b0ec119bdd0d1fb721d887c750337d2a87b4fb48ec80f05193f21a63c5f0d2bf4bf72a966ad6df9abe79edf98cc6169892a6af63028350ecc0dbca1
|
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/baza_models.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: baza_models 0.0.
|
5
|
+
# stub: baza_models 0.0.8 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "baza_models"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.8"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["kaspernj"]
|
14
|
-
s.date = "2016-
|
14
|
+
s.date = "2016-07-07"
|
15
15
|
s.description = "ActiveRecord like models for the Baza database framework"
|
16
16
|
s.email = "k@spernj.org"
|
17
17
|
s.extra_rdoc_files = [
|
data/lib/baza_models/model.rb
CHANGED
@@ -44,8 +44,8 @@ class BazaModels::Model
|
|
44
44
|
end
|
45
45
|
|
46
46
|
QUERY_METHODS = [
|
47
|
-
:average, :all, :any?, :destroy_all, :each, :empty?, :ids, :maximum, :minimum, :none?, :count, :find, :first, :find_first, :last,
|
48
|
-
:size, :select, :includes, :joins, :group, :where, :order, :pluck, :sum, :limit, :to_a, :accessible_by, :ransack
|
47
|
+
:average, :all, :any?, :destroy_all, :each, :empty?, :ids, :maximum, :minimum, :none?, :count, :find, :first, :find_first, :last,
|
48
|
+
:length, :size, :select, :includes, :joins, :group, :where, :order, :pluck, :preloads, :sum, :limit, :to_a, :accessible_by, :ransack
|
49
49
|
].freeze
|
50
50
|
QUERY_METHODS.each do |query_method|
|
51
51
|
(class << self; self; end).__send__(:define_method, query_method) do |*args, &blk|
|
@@ -365,8 +365,6 @@ protected
|
|
365
365
|
if respond_to?(set_method_name)
|
366
366
|
__send__(set_method_name, attribute_value)
|
367
367
|
next
|
368
|
-
else
|
369
|
-
raise "Unknown attribute: #{attribute_name}"
|
370
368
|
end
|
371
369
|
end
|
372
370
|
|
@@ -375,4 +373,9 @@ protected
|
|
375
373
|
|
376
374
|
new_attributes
|
377
375
|
end
|
376
|
+
|
377
|
+
def method_missing(method_name, *args, &blk)
|
378
|
+
return @data.fetch(method_name) if @data.key?(method_name)
|
379
|
+
super
|
380
|
+
end
|
378
381
|
end
|
@@ -220,6 +220,17 @@ describe BazaModels::Query do
|
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
223
|
+
describe "#select" do
|
224
|
+
it "selects extra columns" do
|
225
|
+
user.save!
|
226
|
+
role_user.save!
|
227
|
+
|
228
|
+
role = Role.joins(:user).select("roles.*, users.email AS user_email").first
|
229
|
+
|
230
|
+
expect(role.user_email).to eq "test@example.com"
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
223
234
|
describe "#sum" do
|
224
235
|
it "returns the sum" do
|
225
236
|
5.times do |n|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baza_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: array_enumerator
|