Module: AppKit::Dsl::ResourceDsl
- Included in:
- Resource
- Defined in:
- lib/app_kit/dsl/resource_dsl.rb
Instance Method Summary collapse
-
#action(name, options = {}, &block) ⇒ Object
A DSL method for defining a new action.
-
#before(action, &block) ⇒ Object
DSL method for defining before_actions on resources.
-
#field(name, options = {}, &block) ⇒ Object
A DSL method for defining fields and their options.
-
#icon(icon_name) ⇒ Object
DSL method for defining an icon to be used in the navigation menu for this resource.
-
#show_in_navigation(val = true, position = :left) ⇒ Object
DSL method for displaying resources in the main navigation bar.
Instance Method Details
#action(name, options = {}, &block) ⇒ Object
A DSL method for defining a new action.
Attributes
-
name- The controller action to bind to. -
options- An optional hash of params. -
&block - The code to execute. This block is yielded the model instance
Examples
action :update do |record|
record.parent_record.update_information
end
16 17 18 |
# File 'lib/app_kit/dsl/resource_dsl.rb', line 16 def action(name, ={}, &block) member_actions[name] = AppKit::Action.new(name, self, , &block) end |
#before(action, &block) ⇒ Object
DSL method for defining before_actions on resources.
50 51 52 |
# File 'lib/app_kit/dsl/resource_dsl.rb', line 50 def before(action, &block) before_actions[action] = block if block_given? end |
#field(name, options = {}, &block) ⇒ Object
A DSL method for defining fields and their options.
27 28 29 30 |
# File 'lib/app_kit/dsl/resource_dsl.rb', line 27 def field(name, ={}, &block) field = AppKit::Field.new(model, name, , &block) fields << field end |
#icon(icon_name) ⇒ Object
DSL method for defining an icon to be used in the navigation menu for this resource. These icons use FontAwesome and should relate to the FontAwesome icon name.
59 60 61 |
# File 'lib/app_kit/dsl/resource_dsl.rb', line 59 def icon(icon_name) self. = icon_name end |
#show_in_navigation(val = true, position = :left) ⇒ Object
DSL method for displaying resources in the main navigation bar.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/app_kit/dsl/resource_dsl.rb', line 35 def (val=true, position = :left) if val == true nav_item = AppKit::.new nav_item.resource = self nav_item.position = position nav_item.icon = self. AppKit.application. << nav_item else AppKit.application..delete_if {|i| i.resource == self} end end |