lib/apotomo/rails/controller_methods.rb in apotomo-1.0.1 vs lib/apotomo/rails/controller_methods.rb in apotomo-1.0.2
- old
+ new
@@ -3,23 +3,21 @@
module Apotomo
module Rails
module ControllerMethods
include WidgetShortcuts
+ extend ActiveSupport::Concern
- def self.included(base) #:nodoc:
- base.class_eval do
- extend WidgetShortcuts
- extend ClassMethods
-
- class_inheritable_array :has_widgets_blocks
- self.has_widgets_blocks = []
-
- helper ::Apotomo::Rails::ViewMethods
-
- after_filter :apotomo_freeze
- end
+ included do
+ extend WidgetShortcuts
+
+ class_inheritable_array :has_widgets_blocks
+ self.has_widgets_blocks = []
+
+ helper ::Apotomo::Rails::ViewMethods
+
+ after_filter :apotomo_freeze
end
module ClassMethods
# Yields the root widget to setup your widgets for a controller. The block is executed in
# controller _instance_ context, so you may use instance methods and variables of the
@@ -31,12 +29,10 @@
# root << widget(:comments_widget, 'post-comments', :user => @current_user)
# end
def has_widgets(&block)
has_widgets_blocks << block
end
-
- alias_method :uses_widgets, :has_widgets
end
def bound_use_widgets_blocks
session[:bound_use_widgets_blocks] ||= ProcHash.new
end
@@ -136,28 +132,9 @@
var loc = document.location;
with(window.parent) { setTimeout(function() { window.eval('#{escaped_script}'); window.loc && loc.replace('about:blank'); }, 1) }
</script></body></html>", :content_type => 'text/html'
end
- def respond_to_event(type, options)
- handler = ProcEventHandler.new
- handler.proc = options[:with]
- ### TODO: pass :from => (event source).
-
- # attach once, not every request:
- apotomo_root.evt_table.add_handler_once(handler, :event_type => type)
- end
-
-
-
- ### DISCUSS: rename? should say "this controller action wants apotomo's deep linking!"
- ### DISCUSS: move to deep_link_methods?
- def respond_to_url_change
- return if apotomo_root.find_widget('deep_link') # add only once.
- apotomo_root << widget("apotomo/deep_link_widget", :setup, 'deep_link')
- end
-
-
class ProcHash < Array
def id_for_proc(proc)
proc.to_s.split('@').last
end