Module: Wallaby::ResourcesHelper
Instance Method Summary
collapse
#custom_pagination_stats, #paginatable?
#next_sort_param, #sort_class, #sort_hash, #sort_link
Methods included from FormHelper
#form_type_partial_render, #model_choices
Instance Method Details
#decorate(resource) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/helpers/wallaby/resources_helper.rb', line 6
def decorate(resource)
if resource.respond_to? :map decorator = Wallaby::DecoratorFinder.find_resource resource.first.class
resource.map do |item|
decorator.decorate item
end
else
decorator = Wallaby::DecoratorFinder.find_resource resource.class
decorator.decorate resource
end
end
|
18
19
20
21
22
23
24
|
# File 'lib/helpers/wallaby/resources_helper.rb', line 18
def (resource)
if resource.is_a? Wallaby::ResourceDecorator
resource.resource
else
resource
end
end
|
#index_type_partial_render(options = {}, locals = {}, &block) ⇒ Object
47
48
49
|
# File 'lib/helpers/wallaby/resources_helper.rb', line 47
def index_type_partial_render(options = {}, locals = {}, &block)
type_partial_render options, locals, :index_metadata_of
end
|
#model_decorator(model_class) ⇒ Object
#model_servicer(model_decorator) ⇒ Object
30
31
32
33
|
# File 'lib/helpers/wallaby/resources_helper.rb', line 30
def model_servicer(model_decorator)
model_class = model_decorator.model_class
Wallaby::ServicerFinder.find(model_class).new model_class, model_decorator
end
|
#show_title(decorated) ⇒ Object
51
52
53
54
|
# File 'lib/helpers/wallaby/resources_helper.rb', line 51
def show_title(decorated)
fail ArgumentError unless decorated.is_a? Wallaby::ResourceDecorator
[ to_model_label(decorated.model_class), decorated.to_label ].compact.join ': '
end
|
#type_partial_render(options = {}, locals = {}, metadata_method = :show_metadata_of, &block) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/helpers/wallaby/resources_helper.rb', line 35
def type_partial_render(options = {}, locals = {}, metadata_method = :show_metadata_of, &block)
decorated = locals[:object]
field_name = locals[:field_name].to_s
fail ArgumentError unless field_name.present? && decorated.is_a?(Wallaby::ResourceDecorator)
locals[:metadata] = decorated.send metadata_method, field_name
locals[:value] = decorated.public_send field_name
render(options, locals, &block) or render('string', locals, &block)
end
|