cells 3.5.0.beta2 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,11 +29,11 @@ Rails 2.3:
29
29
 
30
30
  Creating a cell is nothing more than
31
31
 
32
- $ rails generate cell ShoppingCart display
32
+ $ rails generate cell ShoppingCart display -t haml
33
33
  create app/cells/
34
34
  create app/cells/shopping_cart
35
35
  create app/cells/shopping_cart_cell.rb
36
- create app/cells/shopping_cart/display.html.erb
36
+ create app/cells/shopping_cart/display.html.haml
37
37
  create test/cells/shopping_cart_test.rb
38
38
 
39
39
  That looks very familiar.
@@ -56,7 +56,7 @@ Time to improve our cell code. Let's start with <tt>app/cells/shopping_cart_cell
56
56
  user = args[:user]
57
57
  @items = user.items_in_cart
58
58
 
59
- render # renders display.html.erb
59
+ render # renders display.html.haml
60
60
  end
61
61
  end
62
62
 
@@ -65,13 +65,12 @@ Is that a controller? Hell, yeah. We even got a +render+ method as we know it fr
65
65
 
66
66
  == Views
67
67
 
68
- Since a plain call to +render+ will start rendering <tt>app/cells/shopping_cart/display.html.erb</tt> we should put some meaningful markup there.
68
+ Since a plain call to +render+ will start rendering <tt>app/cells/shopping_cart/display.html.haml</tt> we should put some meaningful markup there.
69
69
 
70
- <div id="cart">
71
- You have <%= @items.size %> items in your shopping cart.
72
- </div>
70
+ #cart
71
+ You have #{@items.size} items in your shopping cart.
73
72
 
74
- === Haml? Builder?
73
+ === ERB? Haml? Builder?
75
74
 
76
75
  Yes, Cells support all template types that are supported by Rails itself. Remember- it's a controller!
77
76
 
@@ -8,7 +8,7 @@ module Cell
8
8
  cell = create_cell_for(controller, name, opts) # DISCUSS: we always save options.
9
9
  yield cell if block_given?
10
10
 
11
- return cell.render_state(state, opts) if cell.method(state).arity == 1
11
+ return cell.render_state(state, opts) if cell.state_accepts_args?(state)
12
12
  cell.render_state(state) # backward-compat.
13
13
  end
14
14
 
@@ -89,5 +89,9 @@ module Cell
89
89
  def possible_paths_for_state(state)
90
90
  self.class.find_class_view_for_state(state).reverse!
91
91
  end
92
+
93
+ def state_accepts_args?(state)
94
+ method(state).arity == 1
95
+ end
92
96
  end
93
97
  end
@@ -1,3 +1,3 @@
1
1
  module Cells
2
- VERSION = '3.5.0.beta2'
2
+ VERSION = '3.5.0'
3
3
  end
@@ -150,5 +150,12 @@ class CellModuleTest < ActiveSupport::TestCase
150
150
  should "provide class_from_cell_name" do
151
151
  assert_equal BassistCell, ::Cell::Base.class_from_cell_name('bassist')
152
152
  end
153
+
154
+ should "provide state_accepts_args?" do
155
+ assert_not cell(:bassist).state_accepts_args?(:play)
156
+ assert(cell(:bassist) do
157
+ def listen(args) end
158
+ end.state_accepts_args?(:listen))
159
+ end
153
160
  end
154
161
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cells
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: true
4
+ prerelease: false
5
5
  segments:
6
6
  - 3
7
7
  - 5
8
8
  - 0
9
- - beta2
10
- version: 3.5.0.beta2
9
+ version: 3.5.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Nick Sutterer
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-02-04 00:00:00 +01:00
17
+ date: 2011-02-05 00:00:00 +01:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -185,13 +184,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
184
  required_rubygems_version: !ruby/object:Gem::Requirement
186
185
  none: false
187
186
  requirements:
188
- - - ">"
187
+ - - ">="
189
188
  - !ruby/object:Gem::Version
190
189
  segments:
191
- - 1
192
- - 3
193
- - 1
194
- version: 1.3.1
190
+ - 0
191
+ version: "0"
195
192
  requirements: []
196
193
 
197
194
  rubyforge_project: