Class: LB::Persistence

Inherits:
Object
  • Object
show all
Defined in:
lib/lb/persistence.rb,
lib/lb/persistence/types.rb,
lib/lb/persistence/version.rb,
lib/lb/persistence/settings.rb,
lib/lb/persistence/functions.rb,
lib/lb/persistence/relation/joins.rb,
lib/lb/persistence/model/attributes.rb

Overview

Persistence

Defined Under Namespace

Modules: Functions, Model, Relation, Types Classes: Settings

Constant Summary collapse

VERSION =

Version

'0.0.8'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ Persistence

Returns a new instance of Persistence.



21
22
23
# File 'lib/lb/persistence.rb', line 21

def initialize(settings)
  @settings = settings
end

Instance Attribute Details

#settingsObject (readonly)

Returns the value of attribute settings.



19
20
21
# File 'lib/lb/persistence.rb', line 19

def settings
  @settings
end

Instance Method Details

#configuration_for(connection) ⇒ ROM::Configuration

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create ROM configuration for given connection or URI

Parameters:

  • (Sequel::Database | String)

Returns:

  • (ROM::Configuration)


100
101
102
# File 'lib/lb/persistence.rb', line 100

def configuration_for(connection)
  ROM::Configuration.new(:sql, connection)
end

#configure_for(connection) ⇒ ROM::Configuration

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Configure ROM for given connection or URI

Parameters:

  • (Sequel::Database | String)

Returns:

  • (ROM::Configuration)


66
67
68
# File 'lib/lb/persistence.rb', line 66

def configure_for(connection)
  configure(configuration_for(connection))
end

#connect(*args) ⇒ Sequel::Database

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Connect to database definied by given URI

Parameters:

  • (String)
  • (Hash)

Returns:

  • (Sequel::Database)


54
55
56
# File 'lib/lb/persistence.rb', line 54

def connect(*args)
  Sequel.connect(*args)
end

#containerROM::Conatainer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get ROM container

Returns:

  • (ROM::Conatainer)


31
32
33
# File 'lib/lb/persistence.rb', line 31

def container
  @container ||= rom_setup(uri)
end

#container_from(config) ⇒ ROM::Container

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create ROM container for given config

Parameters:

  • config (ROM::Configuration)

Returns:

  • (ROM::Container)


88
89
90
# File 'lib/lb/persistence.rb', line 88

def container_from(config)
  ROM.container(config)
end

#repository(repository) ⇒ ROM::Repository

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get ROM Repository instance for Repository class

Returns:

  • (ROM::Repository)


41
42
43
# File 'lib/lb/persistence.rb', line 41

def repository(repository)
  repository.new(container)
end

#uriString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get URI

Returns:

  • (String)


76
77
78
# File 'lib/lb/persistence.rb', line 76

def uri
  @uri ||= settings.database_uri
end