Class: RubyRest::SequelApplication
- Inherits:
-
SecureApplication
- Object
- AbstractApplication
- SecureApplication
- RubyRest::SequelApplication
- Defined in:
- lib/rubyrest/application.rb
Overview
Specialization of a secure application, that provides support for Sequel (sequel.rubyforge.org) configuration at startup by implementing the ‘init_database’ method
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
Attributes inherited from AbstractApplication
Instance Method Summary collapse
-
#drop_table(name) ⇒ Object
Convenience method that hides that safely drops a table.
-
#drop_view(name) ⇒ Object
Convenience method that safely drops a view.
- #init_database ⇒ Object
-
#is_a_collection(model) ⇒ Object
Tells whether the specified model will be rendered as a feed or entry.
Methods inherited from SecureApplication
#auto_bind, #create, #delete, #initialize, #register_security, #resolve_principal, #retrieve, #security, #update
Methods inherited from AbstractApplication
#bind, #check_config, #create_tables, #formatter, #initialize, #is_a_service_doc, #parse_request, #register_formatters, #register_resources, #register_service, #register_services, #render_model, #resource, #resource_by_path, resources, #service, #to_resource_class, #to_s, #to_service_class, with_resources
Methods included from ApplicationLogger
Constructor Details
This class inherits a constructor from RubyRest::SecureApplication
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
289 290 291 |
# File 'lib/rubyrest/application.rb', line 289 def db @db end |
Instance Method Details
#drop_table(name) ⇒ Object
Convenience method that hides that safely drops a table
304 305 306 307 308 309 310 311 312 |
# File 'lib/rubyrest/application.rb', line 304 def drop_table( name ) begin @db << "DROP TABLE #{name}" rescue => e @logger.warn e. if @logger.warn? end end |
#drop_view(name) ⇒ Object
Convenience method that safely drops a view
315 316 317 318 319 320 321 322 323 |
# File 'lib/rubyrest/application.rb', line 315 def drop_view( name ) begin @db << "DROP VIEW #{name}" rescue => e @logger.warn e. if @logger.warn? end end |
#init_database ⇒ Object
297 298 299 300 |
# File 'lib/rubyrest/application.rb', line 297 def init_database check_config( :database ) @db = Sequel.open( "sqlite:///#{@config[:database]}", :max_connections => 10, :logger => @logger ) end |
#is_a_collection(model) ⇒ Object
Tells whether the specified model will be rendered as a feed or entry. To be subclassed
293 294 295 |
# File 'lib/rubyrest/application.rb', line 293 def is_a_collection( model ) super( model ) || model.is_a?( Sequel::Dataset ) end |