Class: AdminWidgets::ShowWidget

Inherits:
BaseWidget
  • Object
show all
Defined in:
lib/admin_widgets/show_widget.rb

Direct Known Subclasses

AdminWidgets::Show::FieldsetWidget

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseWidget

#capture, #content_block, #helper, #method_missing, #root

Methods included from Memoization

#memoize

Methods included from Delegation

#delegate

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class AdminWidgets::BaseWidget

Instance Attribute Details

#builderObject (readonly)

Returns the value of attribute builder.



4
5
6
# File 'lib/admin_widgets/show_widget.rb', line 4

def builder
  @builder
end

Instance Method Details

#contentObject



9
10
11
# File 'lib/admin_widgets/show_widget.rb', line 9

def content
  rawtext show
end

#field(name, options = {}) ⇒ Object



23
24
25
26
27
28
# File 'lib/admin_widgets/show_widget.rb', line 23

def field(name, options = {})
  condition = options[:if]
  return if (condition.present? && !resource.instance_eval(&condition))

  rawtext resource.reflect_on_association(name) ? builder.association(name, options) : builder.attribute(name, options)
end

#fieldset(name, options = {}, &block) ⇒ Object



30
31
32
# File 'lib/admin_widgets/show_widget.rb', line 30

def fieldset(name, options = {}, &block)
  widget AdminWidgets::Show::FieldsetWidget.new(options.merge(:name => name, :parent => self, :block => block))
end

#showObject



13
14
15
16
17
18
19
20
21
# File 'lib/admin_widgets/show_widget.rb', line 13

def show
  helper.show_for(resource) do |builder|
    @builder = builder

    capture do
      content_block
    end
  end
end