Class: SimpleAdmin::Builder
- Inherits:
-
Object
- Object
- SimpleAdmin::Builder
- Defined in:
- lib/simple_admin/builder.rb
Instance Attribute Summary collapse
-
#interface ⇒ Object
Returns the value of attribute interface.
Instance Method Summary collapse
- #before(options = {}, &block) ⇒ Object (also: #before_filter)
- #form(options = {}, &block) ⇒ Object
- #index(options = {}, &block) ⇒ Object
-
#initialize(interface, &block) ⇒ Builder
constructor
A new instance of Builder.
- #section(sym, options = {}, &block) ⇒ Object
- #show(options = {}, &block) ⇒ Object
Constructor Details
#initialize(interface, &block) ⇒ Builder
Returns a new instance of Builder.
5 6 7 8 |
# File 'lib/simple_admin/builder.rb', line 5 def initialize(interface, &block) @interface = interface instance_eval(&block) if block_given? end |
Instance Attribute Details
#interface ⇒ Object
Returns the value of attribute interface.
3 4 5 |
# File 'lib/simple_admin/builder.rb', line 3 def interface @interface end |
Instance Method Details
#before(options = {}, &block) ⇒ Object Also known as: before_filter
28 29 30 31 32 33 34 |
# File 'lib/simple_admin/builder.rb', line 28 def before(={}, &block) [:data] = block [:actions] = [:actions] || [:index, :show, :edit, :new, :destroy, :create, :update] [:actions] -= [:except] if [:except] [:actions] &= [:only] if [:only] @interface.before_filters << end |
#form(options = {}, &block) ⇒ Object
20 21 22 |
# File 'lib/simple_admin/builder.rb', line 20 def form(={}, &block) section(:form, , &block) end |
#index(options = {}, &block) ⇒ Object
16 17 18 |
# File 'lib/simple_admin/builder.rb', line 16 def index(={}, &block) section(:index, , &block) end |
#section(sym, options = {}, &block) ⇒ Object
10 11 12 13 14 |
# File 'lib/simple_admin/builder.rb', line 10 def section(sym, ={}, &block) start = Time.now @interface.sections[sym] = SimpleAdmin::Section.new(@interface, sym, , &block) Rails.logger.info("[#{Time.now}] *** Built section #{sym} for #{interface.collection} (elapsed #{Time.now - start})") end |
#show(options = {}, &block) ⇒ Object
24 25 26 |
# File 'lib/simple_admin/builder.rb', line 24 def show(={}, &block) section(:show, , &block) end |