Peeja-abstraction 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,4 +1,4 @@
1
1
  ---
2
- :patch: 1
3
- :major: 0
4
2
  :minor: 0
3
+ :patch: 2
4
+ :major: 0
@@ -21,11 +21,11 @@ class Class
21
21
  def abstract
22
22
  abstract_class = self
23
23
 
24
- raise_if_abstract = lambda do
24
+ raise_if_abstract = lambda do |*args, &block|
25
25
  if self == abstract_class
26
26
  raise AbstractClassError, "#{self} is an abstract class and cannot be instantiated"
27
27
  else
28
- super
28
+ super *args, &block
29
29
  end
30
30
  end
31
31
 
@@ -5,11 +5,22 @@ $: << File.join(File.dirname(__FILE__), '..', 'lib')
5
5
  require 'abstraction'
6
6
 
7
7
  describe "#abstract" do
8
- class Animal
8
+ # Similar to ActiveRecord::Base.new
9
+ class Organism
10
+ def self.new(&b)
11
+ o = super
12
+ yield o if block_given?
13
+ o
14
+ end
15
+ end
16
+
17
+ class Animal < Organism
9
18
  abstract
10
19
  end
11
20
 
12
- class Cat < Animal; end
21
+ class Cat < Animal
22
+ attr_accessor :fur
23
+ end
13
24
 
14
25
  it "makes a class non-instantiable via new" do
15
26
  lambda {
@@ -29,6 +40,14 @@ describe "#abstract" do
29
40
  }.should_not raise_error(AbstractClassError)
30
41
  end
31
42
 
43
+ it "lets subclasses be instantiated via new with a block" do
44
+ cat = nil
45
+ lambda {
46
+ cat = Cat.new { |c| c.fur = :tabby }
47
+ }.should_not raise_error(AbstractClassError)
48
+ cat.fur.should == :tabby
49
+ end
50
+
32
51
  it "lets subclasses be instantiated via allocate" do
33
52
  lambda {
34
53
  Cat.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Peeja-abstraction
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
  - Peter Jaros
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-21 00:00:00 -07:00
12
+ date: 2009-03-31 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -19,13 +19,14 @@ executables: []
19
19
 
20
20
  extensions: []
21
21
 
22
- extra_rdoc_files:
23
- - README.markdown
22
+ extra_rdoc_files: []
23
+
24
24
  files:
25
25
  - README.markdown
26
26
  - VERSION.yml
27
27
  - lib/abstraction.rb
28
28
  - spec/abstraction_spec.rb
29
+ - spec/spec.opts
29
30
  has_rdoc: true
30
31
  homepage: http://github.com/Peeja/abstraction
31
32
  post_install_message: