HornsAndHooves-moribus 0.4.0 → 0.4.1

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: bc7f179d301fc0456db4d78a0d75d54b11a6d02e
4
- data.tar.gz: 3e03e126a009c205683e710d5c5aee4c22bca363
3
+ metadata.gz: 78f55dc7ce48380cd5e0abab56ff669189a78720
4
+ data.tar.gz: e12ffe1c8b66b47b2d7fbebc420273dd4e91c755
5
5
  SHA512:
6
- metadata.gz: fb9b09a579cb4e8c2265785d5f3f971ca73ee20cfda8f4cf129f970e837d6e3c9b6fb408f1a8a6e5935eb9975517e171dfcee4d00e2bb305d68a5e13db486ae6
7
- data.tar.gz: 4d637e308246c0976a656386095fcd178b24c3532946be587fb3c6aae8f07328dd2ca4efc940fd96e46ee1e0ea8bbe366dcddba9558235d82a2ce195e67d28bd
6
+ metadata.gz: 38f92e8d95d1509b6f67b2d8e24242e352024746a989563edfc23c6b1e1fd8cbd5010fb408319b00a14d538a6dcac7821356c7e8093635e7239dedc332ffb2fa
7
+ data.tar.gz: dde51415193dae5676e4444bb12278871459ea3ef8693a3c87926a6333bd0428ea490681a46da1b0ef18ba83e1ce51e83edaed4426be997da04ddb69d762dfea
data/.simplecov CHANGED
@@ -2,17 +2,17 @@ require "simplecov-rcov-text"
2
2
  require "colorized_text"
3
3
  include ColorizedText
4
4
 
5
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
6
6
  SimpleCov::Formatter::RcovTextFormatter,
7
7
  SimpleCov::Formatter::HTMLFormatter
8
- ]
8
+ ])
9
9
  SimpleCov.start do
10
10
  add_filter "/spec/"
11
11
 
12
12
  # Fail the build when coverage is weak:
13
13
  at_exit do
14
14
  SimpleCov.result.format!
15
- threshold, actual = 97.354, SimpleCov.result.covered_percent
15
+ threshold, actual = 96.875, SimpleCov.result.covered_percent
16
16
  if actual < threshold
17
17
  msg = "\nLow coverage: "
18
18
  msg << red("#{actual}%")
@@ -92,8 +92,7 @@ module Moribus
92
92
  end
93
93
 
94
94
  reflection = has_one(name, scope, options)
95
- # Rails 4.1 compatibility fix:
96
- reflection = reflection["#{name}"] if reflection.respond_to? :[]
95
+ reflection = normalize_reflection(reflection, name)
97
96
  reflection.options[:is_current] = true
98
97
  accepts_nested_attributes_for name
99
98
  define_effective_reader_for name
@@ -108,8 +107,7 @@ module Moribus
108
107
  # Extensions::HasAggregatedExtension)
109
108
  def has_aggregated(name, options = {})
110
109
  reflection = belongs_to(name, options)
111
- # Rails 4.1 compatibility fix:
112
- reflection = reflection["#{name}"] if reflection.respond_to? :[]
110
+ reflection = normalize_reflection(reflection, name)
113
111
  reflection.options[:aggregated] = true
114
112
  accepts_nested_attributes_for name
115
113
  define_effective_reader_for name
@@ -118,6 +116,20 @@ module Moribus
118
116
  end
119
117
  private :has_aggregated
120
118
 
119
+ # Normalize reflection for Rails 4.1/4.2.
120
+ def normalize_reflection(reflection, name)
121
+ return reflection unless reflection.respond_to? :[]
122
+
123
+ if reflection.has_key?(name)
124
+ # Rails 4.1
125
+ reflection[name]
126
+ else
127
+ # Rails 4.2
128
+ reflection["#{name}"]
129
+ end
130
+ end
131
+ private :normalize_reflection
132
+
121
133
  # Declare a reader that will build associated object if it does not exist.
122
134
  # We can actually extend an association's readers like:
123
135
  #
@@ -1,3 +1,3 @@
1
1
  module Moribus # :nodoc:
2
- VERSION = "0.4.0" # :nodoc:
2
+ VERSION = "0.4.1" # :nodoc:
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: HornsAndHooves-moribus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - HornsAndHooves