Module: Railsless::ActiveRecord::SinatraExtension

Defined in:
lib/railsless/active_record/sinatra_extension.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.registered(app) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/railsless/active_record/sinatra_extension.rb', line 7

def self.registered(app)
  unless app.respond_to?(:activerecord_config) && app.activerecord_config
    app.set :activerecord_config, Railsless::ActiveRecord::Config.new
  end
  app.set :database, app.database
  app.helpers SinatraExtensionHelper
  app.after { Railsless::ActiveRecord.disconnect! }
end

Instance Method Details

#activerecord_config=(config) ⇒ Object



20
21
22
23
24
# File 'lib/railsless/active_record/sinatra_extension.rb', line 20

def activerecord_config=(config)
  @database = nil
  @activerecord_config = config
  @database = Railsless::ActiveRecord.connect!(config)
end

#databaseObject



16
17
18
# File 'lib/railsless/active_record/sinatra_extension.rb', line 16

def database
  @database ||= Railsless::ActiveRecord.connect!(activerecord_config)
end