Module: TypeStation::ViewHelpers
- Defined in:
- lib/type_station/view_helpers.rb
Instance Method Summary collapse
- #present(object, klass = nil, &block) ⇒ Object
- #ts_admin_toolbar(model, options = {}) ⇒ Object
- #ts_init ⇒ Object
- #type_station_authorise ⇒ Object
- #type_station_current_user ⇒ Object
- #type_station_template(id, content, type = 'text/x-type-station-template') ⇒ Object
- #type_station_toolbar(id, model, partial_name, options = {}) ⇒ Object
Instance Method Details
#present(object, klass = nil, &block) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/type_station/view_helpers.rb', line 4 def present(object, klass = nil, &block) if object.present? klass ||= "#{object.class.to_s}Presenter".constantize block.call(klass.new(object, self)) else nil end end |
#ts_admin_toolbar(model, options = {}) ⇒ Object
24 25 26 |
# File 'lib/type_station/view_helpers.rb', line 24 def (model, = {}) ('ts-admin-bar', model, 'admin_bar', ) if end |
#ts_init ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/type_station/view_helpers.rb', line 13 def ts_init result = ''.html_safe if result << stylesheet_link_tag("//code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css") result << stylesheet_link_tag("type_station/application", media: "all") result << javascript_include_tag("type_station/application") result << cloudinary_js_config end result end |
#type_station_authorise ⇒ Object
32 33 34 |
# File 'lib/type_station/view_helpers.rb', line 32 def instance_eval &TypeStation.config. end |
#type_station_current_user ⇒ Object
28 29 30 |
# File 'lib/type_station/view_helpers.rb', line 28 def type_station_current_user instance_eval &TypeStation.config.current_user end |
#type_station_template(id, content, type = 'text/x-type-station-template') ⇒ Object
40 41 42 |
# File 'lib/type_station/view_helpers.rb', line 40 def type_station_template(id, content, type = 'text/x-type-station-template') content_tag :script, content, id: id, type: type end |
#type_station_toolbar(id, model, partial_name, options = {}) ⇒ Object
36 37 38 |
# File 'lib/type_station/view_helpers.rb', line 36 def (id, model, partial_name, = {}) type_station_template([id, 'template'].join('-'), render(partial: "type_station/toolbars/#{partial_name}", locals: {model: model, options: }).html_safe) end |