Class: DisplayFor::Builder::ResourceBase
- Defined in:
- lib/display_for/builder/resource_base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Attributes inherited from Base
#html_options, #namespace, #resource_class, #template
Instance Method Summary collapse
- #default_actions ⇒ Object
-
#initialize(resource, html_options, template, &block) ⇒ ResourceBase
constructor
A new instance of ResourceBase.
Methods inherited from Base
Constructor Details
#initialize(resource, html_options, template, &block) ⇒ ResourceBase
Returns a new instance of ResourceBase.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/display_for/builder/resource_base.rb', line 6 def initialize(resource, , template, &block) if resource.is_a?(Array) @namespace = resource @resource = @namespace.pop else @namespace = [] @resource = resource end @resource_class = @resource.class super(, template, &block) end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
4 5 6 |
# File 'lib/display_for/builder/resource_base.rb', line 4 def resource @resource end |
Instance Method Details
#default_actions ⇒ Object
20 21 22 23 24 |
# File 'lib/display_for/builder/resource_base.rb', line 20 def default_actions action :list, :link_to => lambda { |r| @namespace + [@resource_class]}, :class => 'btn btn-small' action :edit, :link_to => lambda { |r| [:edit] + @namespace + [r] }, :class => 'btn btn-small' action :delete, :method => :delete, :confirm => "Are you sure?", :class => 'btn btn-small btn-danger' end |