Class: WingedCouch::Abstract::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/winged_couch/abstract/database.rb

Overview

Class which represents abstract database.

It implements base logic for database class.

Examples:

database1 = WingedCouch::Abstract::Database.new("database-name")
# => #<WingedCouch::Abstract::Database name='database-name'>

database2 = WingedCouch::Abstract::Database.new("database-name")
# => #<WingedCouch::Abstract::Database name='database-name'>

database3 = WingedCouch::Abstract::Database.new("database-name2")
# => #<WingedCouch::Abstract::Database name='database-name2'>

database1 == database2
# => true

database1 == database3
# => false

Direct Known Subclasses

Native::Database

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Database


27
28
29
# File 'lib/winged_couch/abstract/database.rb', line 27

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


25
26
27
# File 'lib/winged_couch/abstract/database.rb', line 25

def name
  @name
end

Instance Method Details

#==(other) ⇒ true, false

Compares database with passed object

Returns true if passed object has same class and database name

38
39
40
# File 'lib/winged_couch/abstract/database.rb', line 38

def ==(other)
  other.instance_of?(self.class) && name.present? && name == other.name
end

#inspectString

Returns the contents of the document as a nicely formatted string.


46
47
48
# File 'lib/winged_couch/abstract/database.rb', line 46

def inspect
  "#<#{self.class} name='#{self.name}'>"
end