Module: Wallaby::ResourcesHelper
- Includes:
- FormHelper, IndexHelper
- Defined in:
- lib/helpers/wallaby/resources_helper.rb
Overview
Resources helper
Instance Method Summary collapse
-
#decorate(resource) ⇒ Object
Wrap resource into a decorator.
-
#default_metadata ⇒ Object
Shortcut for ‘Wallaby.configuration.metadata.
-
#extract(resource) ⇒ Object
Get the origin resource object.
- #model_decorator(model_class) ⇒ Wallaby::ModelDecorator
-
#show_title(decorated) ⇒ String
Title for show page of given resource.
-
#type_partial_render(options = {}, locals = {}, &block) ⇒ Object
Render partial for index/show.
Methods included from IndexHelper
#all_label, #export_link, #filter_label, #filter_link, #paginate, #sort_link_builder
Methods included from FormHelper
#form_type_partial_render, #hint_of, #polymorphic_options, #remote_url
Instance Method Details
#decorate(resource) ⇒ Object
Wrap resource into a decorator
22 23 24 25 26 27 |
# File 'lib/helpers/wallaby/resources_helper.rb', line 22 def decorate(resource) return resource if resource.is_a? ResourceDecorator return resource.map { |item| decorate item } if resource.respond_to? :map decorator = Map.resource_decorator_map resource.class decorator ? decorator.new(resource) : resource end |
#default_metadata ⇒ Object
Shortcut for ‘Wallaby.configuration.metadata
14 15 16 |
# File 'lib/helpers/wallaby/resources_helper.rb', line 14 def Wallaby.configuration. end |
#extract(resource) ⇒ Object
Get the origin resource object
32 33 34 35 |
# File 'lib/helpers/wallaby/resources_helper.rb', line 32 def extract(resource) return resource.resource if resource.is_a? ResourceDecorator resource end |
#model_decorator(model_class) ⇒ Wallaby::ModelDecorator
9 10 11 |
# File 'lib/helpers/wallaby/resources_helper.rb', line 9 def model_decorator(model_class) Map.model_decorator_map model_class end |
#show_title(decorated) ⇒ String
Title for show page of given resource
45 46 47 48 49 50 |
# File 'lib/helpers/wallaby/resources_helper.rb', line 45 def show_title(decorated) raise ::ArgumentError unless decorated.is_a? ResourceDecorator [ to_model_label(decorated.model_class), decorated.to_label ].compact.join ': ' end |
#type_partial_render(options = {}, locals = {}, &block) ⇒ Object
Render partial for index/show
38 39 40 |
# File 'lib/helpers/wallaby/resources_helper.rb', line 38 def type_partial_render( = {}, locals = {}, &block) PartialRenderer.render self, , locals, params[:action], &block end |