Module: Reactive::Mvc::View::Helpers

Defined in:
lib/reactive-mvc/view/helpers.rb

Instance Method Summary collapse

Instance Method Details

#inject_output_helpersObject



3
4
5
6
7
8
9
10
# File 'lib/reactive-mvc/view/helpers.rb', line 3

def inject_output_helpers
  <<-EOS
helpers_module = HelperModule.new #{output_helper_names.inspect}, <<-EOC
#{read_output_helpers.gsub('#', '\#')}
EOC
extend(*helpers_module.helpers)
  EOS
end

#output_helper_namesObject



12
13
14
15
# File 'lib/reactive-mvc/view/helpers.rb', line 12

def output_helper_names
  parts = controller_name.split('/')
  (["application_helper.#{request.format}.rb"] + Enumerable::Enumerator.new(parts, :each_index).collect{|i| "#{parts[0..i].join('/')}_helper.#{request.format}.rb"}).uniq.select{|path| File.file?(Reactive.path_for(:helper, path))}
end

#read_output_helpers(names = output_helper_names) ⇒ Object



17
18
19
# File 'lib/reactive-mvc/view/helpers.rb', line 17

def read_output_helpers(names = output_helper_names)
  names.inject("") {|code, path| code << File.read(Reactive.path_for(:helper, path))}
end