Browse files

save @options in the constructor now, bypassing cells behaviour. sinc…

…e in cells-3.7 this got obsolete we simply do it ourselves.

check method arity in #invoke so trigger states still can receive an optional evt instance. this will soon be changed to an obligatory argument.
  • Loading branch information...
1 parent 1212694 commit b08d676d0d1b6272eafc0f7042ee85b713abd512 @apotonick committed Oct 14, 2011
Showing with 7 additions and 13 deletions.
  1. +4 −2 lib/apotomo/widget.rb
  2. +3 −11 test/rails/view_helper_test.rb
View
6 lib/apotomo/widget.rb
@@ -72,14 +72,16 @@ class Widget < Cell::Base
undef :display # We don't want #display to be listed in #internal_methods.
alias_method :widget_id, :name
+ attr_reader :options
after_initialize do
run_hook :has_widgets, self
end
def initialize(parent, id, options={})
- super(parent, options) # TODO: do that as long as cells do need a parent_controller. remember to remove options for cells 3.7.
+ super(parent) # TODO: do that as long as cells do need a parent_controller.
+ @options = options
@name = id
@visible = true
@@ -99,7 +101,7 @@ def visible?
# Invokes +state+ and hopefully returns the rendered content.
def invoke(state, *args)
- return render_state(state, *args) if state_accepts_args?(state)
+ return render_state(state, *args) if method(state).arity != 0 # TODO: remove check and make trigger states receive the evt default.
render_state(state)
end
View
14 test/rails/view_helper_test.rb
@@ -7,17 +7,9 @@ class ViewHelperTest < Apotomo::TestCase
# TODO: use Cell::TestCase#in_view here.
def in_view(subject, &block)
- if subject.kind_of?(Apotomo::Widget)
- subject.options[:block] = block
- else
- subject = subject.new(@controller, 'mum', :block => block)
- end
-
- setup_test_states_in(subject) unless subject.respond_to?(:in_view)# add #in_view state to subject cell.
-
- subject.class.action_methods << "in_view"
-
- subject.invoke(:in_view)
+ subject = subject.new(@controller, :mum) unless subject.kind_of?(Apotomo::Widget)
+ setup_test_states_in(subject)
+ subject.invoke(:in_view, block)
end
def mouse_mock(id='mum', opts={}, &block)
mouse = MouseWidget.new(parent_controller, id, opts)

0 comments on commit b08d676

Please sign in to comment.