Class: Faststep::Db
- Inherits:
-
Object
- Object
- Faststep::Db
- Defined in:
- lib/faststep/db.rb,
ext/faststep/db.c
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #collection(collection_name) ⇒ Object (also: #[])
- #collection_names ⇒ Object
- #collections ⇒ Object
- #command ⇒ Object
- #drop ⇒ Object
- #get_last_error ⇒ Object
-
#initialize(name, connection) ⇒ Db
constructor
A new instance of Db.
Constructor Details
#initialize(name, connection) ⇒ Db
Returns a new instance of Db.
5 6 7 8 |
# File 'lib/faststep/db.rb', line 5 def initialize(name, connection) @name = name @connection = connection end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
3 4 5 |
# File 'lib/faststep/db.rb', line 3 def connection @connection end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/faststep/db.rb', line 3 def name @name end |
Instance Method Details
#collection(collection_name) ⇒ Object Also known as: []
10 11 12 |
# File 'lib/faststep/db.rb', line 10 def collection(collection_name) Collection.new(collection_name, self) end |
#collection_names ⇒ Object
16 17 18 19 20 |
# File 'lib/faststep/db.rb', line 16 def collection_names names = collections_info.map {|doc| doc["name"] } names.reject! {|name| name.index(@name).nil? || name.index('$') } names.map {|name| name.sub("#{@name}.", "") } end |
#collections ⇒ Object
22 23 24 25 26 |
# File 'lib/faststep/db.rb', line 22 def collections collection_names.map do |collection_name| Collection.new(collection_name, self) end end |