module Wallaby::ResourcesHelper

Resources helper

Public Instance Methods

first_field_by(*conditions) { |: current_fields| ... } click to toggle source

To find the first field that meets given conditions. @example To find summary field whose name contains summary and type is string:

first_field_by({ name: /summary/, type: 'string' })

@param conditions [Array<Hash>] @return [String, Symbol] field name when found @return [nil] when not found

# File lib/helpers/wallaby/resources_helper.rb, line 43
def first_field_by(*conditions)
  fields = block_given? ? yield : current_fields
  FieldUtils.first_field_by(*conditions, fields)
end
show_title(decorated) click to toggle source

Title for show page of given resource @param decorated [Wallaby::ResourceDecorator] @return [String]

# File lib/helpers/wallaby/resources_helper.rb, line 29
def show_title(decorated)
  raise ::ArgumentError unless decorated.is_a? ResourceDecorator

  [
    to_model_label(decorated.model_class), decorated.to_label
  ].compact.join ': '
end
type_render(partial_name = '', locals = {}, &block) click to toggle source

Render type cell/partial @param partial_name [String] @param locals [Hash]

# File lib/helpers/wallaby/resources_helper.rb, line 22
def type_render(partial_name = '', locals = {}, &block)
  TypeRenderer.render self, partial_name, locals, &block
end