Class: RubyRest::SequelApplication

Inherits:
SecureApplication show all
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

Attributes inherited from AbstractApplication

#config, #logger

Instance Method Summary collapse

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

#init_logger

Constructor Details

This class inherits a constructor from RubyRest::SecureApplication

Instance Attribute Details

#dbObject (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.message 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.message if @logger.warn?
  end
  
end

#init_databaseObject



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