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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1efdb34a4c3ec8e1fbefa2bff8e24906d880d77b
4
- data.tar.gz: 7951d6da1f4bc03c5a77de5494e2431c9d5628b4
3
+ metadata.gz: 559ac4422c97943f4d90db128a3ee939b7d81b5f
4
+ data.tar.gz: 1e5d6e48878a1375650a6775d9e2183bcb2b53d4
5
5
  SHA512:
6
- metadata.gz: b82f2aabc5d395d51ebe3128b8fdb6a033f5f840cea62a830287925046b0d2e3d56cf0d63198581ff37cc603bad7cbadc8220d4656570d6812e0db0d6f29650b
7
- data.tar.gz: d88efce0327adc63a0c619c8172aa55c3000a7c6f82c031eaecc65b0129c7f2f83173f7e5d696b90b3aef6302328490e1df4c0b7dba4d38139b51789799135f5
6
+ metadata.gz: 97b3c4a05c69c616b7ba4eec678b1580a5cc9897bda2063c345f5245fa6340911b3b45558b0072b09b6c4c6ab1d7cba9ae8fe6bac6d283eea2e6cd3eb4341424
7
+ data.tar.gz: 640af41b9b0ec119bdd0d1fb721d887c750337d2a87b4fb48ec80f05193f21a63c5f0d2bf4bf72a966ad6df9abe79edf98cc6169892a6af63028350ecc0dbca1
data/README.md CHANGED
@@ -79,6 +79,7 @@ User.to_enum
79
79
  User.first
80
80
  User.last
81
81
  User.order(:id).reverse_order
82
+ Role.joins(:user).select("roles.*, users.email AS user_email").first.user_email #=> "test@example.com"
82
83
  ```
83
84
 
84
85
  ### Ransack
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
@@ -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.7 ruby lib
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.7"
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-05-05"
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 = [
@@ -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, :length,
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.7
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-05-05 00:00:00.000000000 Z
11
+ date: 2016-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: array_enumerator