Sha256: e4fb900caca5e050bbf63b410d51e3a273c72d8afd7633668578bfc6926822a1
Contents?: true
Size: 1.7 KB
Versions: 2
Compression:
Stored size: 1.7 KB
Contents
require 'active_support' require 'active_support/concern' require 'fortitude/rails/yielded_object_outputter' module Fortitude class Widget module Helpers extend ActiveSupport::Concern # PUBLIC API def invoke_helper(name, *args, &block) @_fortitude_rendering_context.helpers_object.send(name, *args, &block) end module ClassMethods # PUBLIC API def helper(*args) options = args.extract_options! options.assert_valid_keys(:transform, :call, :output_yielded_methods) args.each do |name| source_method_name = options[:call] || name prefix = "return" suffix = "" case (transform = options[:transform]) when :output_return_value prefix = "text" suffix = "; nil" when :return_output prefix = "return capture { " suffix = " }" when :none, nil, false then nil else raise ArgumentError, "Invalid value for :transform: #{transform.inspect}" end block_transform = if (yielded_methods_to_output = options[:output_yielded_methods]) "effective_block = ::Fortitude::Rails::YieldedObjectOutputter.wrap_block_as_needed(self, #{name.inspect}, block, #{yielded_methods_to_output.inspect})" else "effective_block = block" end text = <<-EOS def #{name}(*args, &block) #{block_transform} #{prefix}(@_fortitude_rendering_context.helpers_object.#{source_method_name}(*args, &effective_block))#{suffix} end EOS helpers_module.module_eval(text) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fortitude-0.9.4-java | lib/fortitude/widget/helpers.rb |
fortitude-0.9.4 | lib/fortitude/widget/helpers.rb |