module ViewObject
Constants
- VERSION
Public Class Methods
config()
click to toggle source
Global settings for ViewObject
# File lib/view_object/config.rb, line 10 def self.config @config end
configure() { |config ||= configuration| ... }
click to toggle source
# File lib/view_object/config.rb, line 5 def self.configure(&block) yield @config ||= ViewObject::Configuration.new end
Public Instance Methods
before_render(*names, &block)
click to toggle source
# File lib/view_object.rb, line 43 def before_render(*names, &block) _insert_callbacks(names, block) do |name, options| set_callback(:render, :before, name, options) end end
dispatch_view_object(controller)
click to toggle source
# File lib/view_object.rb, line 12 def dispatch_view_object(controller) return unless is_view_object_only_action(@@view_object_only, controller) return if is_view_object_ignore_action(@@view_object_ignore, controller) # dispatch actions Dispatcher.dispatch_view_object(controller) end
is_view_object_ignore_action(actions, controller)
click to toggle source
# File lib/view_object.rb, line 24 def is_view_object_ignore_action(actions, controller) ignore_actions = actions.is_a?(Array) ? actions.map{ |action| action.to_s } : actions.to_s return (ignore_actions.present? && ignore_actions.include?(controller.params[:action].to_s)) end
is_view_object_only_action(actions, controller)
click to toggle source
# File lib/view_object.rb, line 19 def is_view_object_only_action(actions, controller) only_actions = actions.is_a?(Array) ? actions.map{ |action| action.to_s } : actions.to_s return (only_actions.blank? || only_actions.include?(controller.params[:action].to_s)) end
render(*options, &block)
click to toggle source
Calls superclass method
# File lib/view_object.rb, line 36 def render(*options, &block) run_callbacks(:render) do super end end
view_object_before_render(controller)
click to toggle source
# File lib/view_object.rb, line 29 def view_object_before_render(controller) vo = controller.instance_variable_get(:@view_object) return if vo.blank? return unless vo.respond_to?(:before_render) vo.send(:before_render) end
view_object_ignore(*actions)
click to toggle source
# File lib/view_object.rb, line 53 def view_object_ignore(*actions) @@view_object_ignore = actions end
view_object_only(*actions)
click to toggle source
# File lib/view_object.rb, line 49 def view_object_only(*actions) @@view_object_only = actions end