stipend 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/stipend/overrides.rb +2 -2
- data/lib/stipend/version.rb +1 -1
- data/spec/overrides_spec.rb +6 -6
- metadata +1 -1
data/lib/stipend/overrides.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Stipend
|
2
2
|
module Overrides
|
3
|
-
def override_inherited_model_name(
|
3
|
+
def override_inherited_model_name(overridden_model_name_class)
|
4
4
|
class_eval <<-SOMETEXT
|
5
5
|
def self.inherited(child)
|
6
6
|
child.instance_eval do
|
7
7
|
def model_name
|
8
|
-
|
8
|
+
::#{overridden_model_name_class}.model_name
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
data/lib/stipend/version.rb
CHANGED
data/spec/overrides_spec.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class TestType < ActiveRecord::Base
|
4
4
|
include Stipend
|
5
5
|
|
6
|
-
override_inherited_model_name
|
6
|
+
override_inherited_model_name TestType
|
7
7
|
end
|
8
8
|
|
9
|
-
class
|
9
|
+
class AlphaTestType < TestType
|
10
10
|
end
|
11
11
|
|
12
12
|
describe Stipend::Overrides do
|
13
13
|
describe '.override_inherited_model_name' do
|
14
|
-
let(:alpha_type) {
|
14
|
+
let(:alpha_type) { AlphaTestType.new(:foo => 1, :bar => 'qux') }
|
15
15
|
|
16
16
|
describe '#model_name' do
|
17
17
|
it 'is always the model name of the base class' do
|
18
|
-
alpha_type.class.model_name.should eql '
|
18
|
+
alpha_type.class.model_name.should eql 'TestType'
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'is always the model name of the base class' do
|
22
|
-
|
22
|
+
TestType.model_name.should eql 'TestType'
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|