Class: SinatraAdmin::Config
- Inherits:
-
Object
- Object
- SinatraAdmin::Config
- Defined in:
- lib/sinatra-admin/config.rb
Constant Summary collapse
- ATTRIBUTES =
[:root, :admin_model]
Instance Method Summary collapse
- #admin_model ⇒ Object
- #default_route ⇒ Object
-
#reset! ⇒ Object
USE THIS METHOD CAREFULLY! ########### Sets ALL config to nil and remove ALL registered routes.
-
#routes ⇒ Object
Store all registered routes.
Instance Method Details
#admin_model ⇒ Object
21 22 23 |
# File 'lib/sinatra-admin/config.rb', line 21 def admin_model @admin_model ||= SinatraAdmin::Admin end |
#default_route ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sinatra-admin/config.rb', line 9 def default_route @default_route ||= if root route = root.underscore.pluralize raise RegistrationException, "The resource #{root} was not registered" unless routes.include?(route) "/admin/#{route}" else raise RegistrationException, 'You should register at least one resource' if routes.empty? "/admin/#{routes.first}" end end |
#reset! ⇒ Object
USE THIS METHOD CAREFULLY! ########### Sets ALL config to nil and remove ALL registered routes. It means that this method is going to remove the WHOLE SinatraAdmin functionality
40 41 42 43 |
# File 'lib/sinatra-admin/config.rb', line 40 def reset! ATTRIBUTES.each {|attr| send("#{attr.to_s}=", nil)} routes.clear end |
#routes ⇒ Object
Store all registered routes. Executing:
SinatraAdmin.register('User')
SinatraAdmin.register('Tags')
The result is going to be:
@routes => ['users', 'tags']
32 33 34 |
# File 'lib/sinatra-admin/config.rb', line 32 def routes @routes ||= [] end |