fixjour-2 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ module Fixjour
7
7
  def define
8
8
  block = @block
9
9
  klass = find_class
10
- klass_name = klass.model_name.singular
10
+ klass_name = find_class_name
11
11
 
12
12
  Fixjour.module_eval do
13
13
  define_method("new_" + klass_name) do |*overrides|
@@ -30,9 +30,14 @@ module Fixjour
30
30
  private
31
31
 
32
32
  def find_class
33
- @options[:class] || @model.is_a?(Symbol) ?
33
+ @options[:class] || (@model.is_a?(Symbol) ?
34
34
  @model.to_s.classify.constantize :
35
- @model
35
+ @model)
36
+ end
37
+
38
+ def find_class_name
39
+ return @model.to_s if @model.is_a?(Symbol) && @options[:class]
40
+ find_class.model_name.singular
36
41
  end
37
42
  end
38
43
  end
@@ -17,6 +17,11 @@ describe "Fixjour Builders" do
17
17
  comment.text = "comment #{counter(:comment)}"
18
18
  comment.article = new_article
19
19
  end
20
+
21
+ define :content, :class => Article::Comment do |comment|
22
+ comment.text = "comment #{counter(:comment)}"
23
+ comment.article = new_article
24
+ end
20
25
  end
21
26
 
22
27
  user = new_user
@@ -47,6 +52,9 @@ describe "Fixjour Builders" do
47
52
  # It works with namespaces
48
53
  comment = new_comment
49
54
 
55
+ # It works with a symbol representing a non-existent class
56
+ new_content
57
+
50
58
  # It works with counters
51
59
  first_comment = new_comment
52
60
  second_comment = new_comment
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixjour-2
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pat Nakajima
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-27 00:00:00 -05:00
19
- default_executable:
18
+ date: 2011-01-27 00:00:00 Z
20
19
  dependencies: []
21
20
 
22
21
  description:
@@ -32,12 +31,11 @@ files:
32
31
  - Gemfile.lock
33
32
  - README
34
33
  - lib/fixjour.rb
35
- - lib/fixjour/counter.rb
36
34
  - lib/fixjour/builder.rb
37
35
  - lib/fixjour/dsl.rb
36
+ - lib/fixjour/counter.rb
38
37
  - spec/fixjour_spec.rb
39
38
  - spec/spec_helper.rb
40
- has_rdoc: true
41
39
  homepage:
42
40
  licenses: []
43
41
 
@@ -67,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
65
  requirements: []
68
66
 
69
67
  rubyforge_project:
70
- rubygems_version: 1.6.2
68
+ rubygems_version: 1.8.24
71
69
  signing_key:
72
70
  specification_version: 3
73
71
  summary: Fixjour Again