stipend 0.0.1 → 0.0.2

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.
@@ -1,10 +1,12 @@
1
1
  require 'stipend/transposable'
2
2
  require 'stipend/unprotectable'
3
+ require 'stipend/overrides'
3
4
  require 'stipend/version'
4
5
 
5
6
  module Stipend
6
7
  def self.included(base)
7
8
  base.send(:include, ::Stipend::Transposable)
9
+ base.send(:extend, ::Stipend::Overrides)
8
10
  base.send(:extend, ::Stipend::Unprotectable)
9
11
  end
10
12
  end
@@ -0,0 +1,17 @@
1
+ module Stipend
2
+ module Overrides
3
+ def override_inherited_model_name(overridden_model_name)
4
+ class_eval <<-SOMETEXT
5
+ def self.inherited(child)
6
+ child.instance_eval do
7
+ def model_name
8
+ '#{overridden_model_name}'
9
+ end
10
+ end
11
+
12
+ super
13
+ end
14
+ SOMETEXT
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module Stipend
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ class OverridesTestType < ActiveRecord::Base
4
+ include Stipend
5
+
6
+ override_inherited_model_name OverridesTestType.model_name
7
+ end
8
+
9
+ class OverridesAlphaTestType < OverridesTestType
10
+ end
11
+
12
+ describe Stipend::Overrides do
13
+ describe '.override_inherited_model_name' do
14
+ let(:alpha_type) { OverridesAlphaTestType.new(:foo => 1, :bar => 'qux') }
15
+
16
+ describe '#model_name' do
17
+ it 'is always the model name of the base class' do
18
+ alpha_type.class.model_name.should eql 'OverridesTestType'
19
+ end
20
+
21
+ it 'is always the model name of the base class' do
22
+ OverridesTestType.model_name.should eql 'OverridesTestType'
23
+ end
24
+ end
25
+ end
26
+ end
@@ -20,6 +20,12 @@ RSpec.configure do |config|
20
20
  t.string :foo
21
21
  t.string :bar
22
22
  end
23
+
24
+ create_table :overrides_test_types do |t|
25
+ t.string :type
26
+ t.string :foo
27
+ t.string :bar
28
+ end
23
29
  end
24
30
  end
25
31
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stipend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-07 00:00:00.000000000 Z
13
+ date: 2012-10-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -148,6 +148,7 @@ extra_rdoc_files:
148
148
  - README.md
149
149
  - LICENSE
150
150
  files:
151
+ - lib/stipend/overrides.rb
151
152
  - lib/stipend/transposable.rb
152
153
  - lib/stipend/unprotectable.rb
153
154
  - lib/stipend/version.rb
@@ -155,6 +156,7 @@ files:
155
156
  - Rakefile
156
157
  - README.md
157
158
  - LICENSE
159
+ - spec/overrides_spec.rb
158
160
  - spec/spec_helper.rb
159
161
  - spec/support/focused.rb
160
162
  - spec/support/pending.rb
@@ -187,6 +189,7 @@ specification_version: 3
187
189
  summary: STIpend is a quick way to allow assignment and modification of Single Table
188
190
  Inheritance in Rails.
189
191
  test_files:
192
+ - spec/overrides_spec.rb
190
193
  - spec/spec_helper.rb
191
194
  - spec/support/focused.rb
192
195
  - spec/support/pending.rb