Module: Presenting::Helpers
- Defined in:
- lib/presenting/helpers.rb
Instance Method Summary collapse
- #present(*args, &block) ⇒ Object
-
#present_checkbox_search(field, options = {}) ⇒ Object
presents a checkbox search widget for the given field (a Presentation::FieldSearch::Field, probably).
-
#present_dropdown_search(field, options = {}) ⇒ Object
presents a dropdown/select search widget for the given field (a Presentation::FieldSearch::Field, probably).
-
#present_text_search(field, options = {}) ⇒ Object
presents a text search widget for the given field (a Presentation::FieldSearch::Field, probably).
- #presentation_javascript(*args) ⇒ Object
- #presentation_stylesheets(*args) ⇒ Object
Instance Method Details
#present(*args, &block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/presenting/helpers.rb', line 15 def present(*args, &block) = args.length > 1 ? args. : {} if args.first.is_a? Symbol object, presentation = nil, args.first else object, presentation = args.first, args.second end if presentation klass = "Presentation::#{presentation.to_s.camelcase}".constantize rescue nil if klass instance = klass.new(, &block) instance.presentable = object instance.controller = controller instance.render elsif respond_to?(method_name = "present_#{presentation}") send(method_name, object, ) else raise ArgumentError, "unknown presentation `#{presentation}'" end elsif object.respond_to?(:loaded?) # AssociationProxy present_association(object, ) else present_by_class(object, ) end end |
#present_checkbox_search(field, options = {}) ⇒ Object
presents a checkbox search widget for the given field (a Presentation::FieldSearch::Field, probably)
50 51 52 53 |
# File 'lib/presenting/helpers.rb', line 50 def present_checkbox_search(field, = {}) current_value = (params[:search][field.param][:value] rescue nil) check_box_tag [:name], '1', current_value.to_s == '1' end |
#present_dropdown_search(field, options = {}) ⇒ Object
presents a dropdown/select search widget for the given field (a Presentation::FieldSearch::Field, probably)
56 57 58 59 |
# File 'lib/presenting/helpers.rb', line 56 def present_dropdown_search(field, = {}) current_value = (params[:search][field.param][:value] rescue nil) select_tag [:name], ((field.), current_value) end |
#present_text_search(field, options = {}) ⇒ Object
presents a text search widget for the given field (a Presentation::FieldSearch::Field, probably)
44 45 46 47 |
# File 'lib/presenting/helpers.rb', line 44 def present_text_search(field, = {}) current_value = (params[:search][field.param][:value] rescue nil) text_field_tag [:name], h(current_value) end |
#presentation_javascript(*args) ⇒ Object
9 10 11 12 13 |
# File 'lib/presenting/helpers.rb', line 9 def presentation_javascript(*args) warn "[DEPRECATION] presentation_javascript is deprecated. Please use the javascripts" << "that are copied to public/javascripts/presenting/* on boot." javascript_include_tag presentation_javascript_path(args.sort.join(','), :format => 'js') end |
#presentation_stylesheets(*args) ⇒ Object
3 4 5 6 7 |
# File 'lib/presenting/helpers.rb', line 3 def presentation_stylesheets(*args) warn "[DEPRECATION] presentation_stylesheets is deprecated. Please use the stylesheets" << "that are copied to public/stylesheets/presenting/* on boot." stylesheet_link_tag presentation_stylesheet_path(args.sort.join(','), :format => 'css') end |