acts_as_default 0.0.1 → 0.0.2

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: 21e3b7d9b89c9e22291465716fe3ec253d338183
4
- data.tar.gz: 3d34ac2a23342c69cd2028911143beee457a142d
3
+ metadata.gz: 5128904868f31ddcfb3b9fde58d7f1bd359b46cd
4
+ data.tar.gz: f011f17fb0074fdfe148de75edce3f84a5f5df41
5
5
  SHA512:
6
- metadata.gz: f8edf32e8a2a8a2a4c14e47186e08e23ad12b19d09546bb6dc358025596d6d1e722ce0d99dbec098996739b91a91f835c55d2522737aa07adae2fcb305e6a97e
7
- data.tar.gz: aca6cc979cad90f12b09afe959b000b994d07c9c5b6dd93a3d93b4a068f27561fbcdb789b46d09b780f1981f11cad37277480e1788faa0a256ec7bd4bf912a4d
6
+ metadata.gz: d925dab94a01e0491d682ffe3c0c294ba66e5e2e4913ef97437560f7daaeaa78387dbe03e8283eef24877f060a78acedb43ffe0b221b8a84332680978144cae6
7
+ data.tar.gz: 727655a84f30d0093f0463f9eeb75c224ed87c61f22a5a17bb3728f4b64cb0aa2a4009dd313146e2e9bdd32a2b9acab9476c882ae8116b7d4a8c6a51fdde43c5
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in acts_as_default.gemspec
4
4
  gemspec
5
+
6
+ gem 'coveralls', require: false
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Build Status](https://travis-ci.org/MirkoMignini/acts_as_default.png?branch=master)](https://travis-ci.org/MirkoMignini/acts_as_default)
2
-
2
+ [![Coverage Status](https://coveralls.io/repos/MirkoMignini/acts_as_default/badge.png)](https://coveralls.io/r/MirkoMignini/acts_as_default)
3
3
  # ActsAsDefault
4
4
 
5
5
  Using acts as default you can set a default row in your activerecord collection, also for has_many relationships
@@ -66,9 +66,10 @@ module ActsAsDefault
66
66
 
67
67
  def get_default_object
68
68
  if self.class.field_key.nil?
69
- self.class.where("[default] = ?", true).first
69
+ self.class.where(default: true).first
70
70
  else
71
- self.class.where("[#{self.class.field_key}] = ? AND [default] = ?", self[self.class.field_key], true).first
71
+ key = self.class.field_key
72
+ self.class.where("#{key} = :key and default = :default", {key: self[key], default: true}).first
72
73
  end
73
74
  end
74
75
  end
@@ -1,3 +1,3 @@
1
1
  module ActsAsDefault
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -3,6 +3,9 @@ require 'active_record'
3
3
  require 'minitest/autorun'
4
4
  require_relative '../lib/acts_as_default'
5
5
  require_relative 'test_objects'
6
+ require 'coveralls'
7
+
8
+ Coveralls.wear!
6
9
 
7
10
  class TestAll < Minitest::Unit::TestCase
8
11
 
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_default
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mirko Mignini
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-04 00:00:00.000000000 Z
11
+ date: 2014-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 4.0.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 4.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.5'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.5'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sqlite3
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: ''
@@ -87,8 +87,8 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gitignore
91
- - .travis.yml
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
92
  - Gemfile
93
93
  - LICENSE.txt
94
94
  - README.md
@@ -108,12 +108,12 @@ require_paths:
108
108
  - lib
109
109
  required_ruby_version: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - '>='
111
+ - - ">="
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - '>='
116
+ - - ">="
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []