Class: Txdb::Table
- Inherits:
-
Object
- Object
- Txdb::Table
- Defined in:
- lib/txdb/table.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#source_lang ⇒ Object
readonly
Returns the value of attribute source_lang.
Instance Method Summary collapse
- #db ⇒ Object
-
#initialize(database, options = {}) ⇒ Table
constructor
A new instance of Table.
- #read_content ⇒ Object
- #resource ⇒ Object
- #write_content(content, locale) ⇒ Object
Constructor Details
#initialize(database, options = {}) ⇒ Table
Returns a new instance of Table.
9 10 11 12 13 14 |
# File 'lib/txdb/table.rb', line 9 def initialize(database, = {}) @database = database @name = .fetch(:name) @columns = .fetch(:columns) @source_lang = .fetch(:source_lang) end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
6 7 8 |
# File 'lib/txdb/table.rb', line 6 def columns @columns end |
#database ⇒ Object (readonly)
Returns the value of attribute database.
6 7 8 |
# File 'lib/txdb/table.rb', line 6 def database @database end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/txdb/table.rb', line 6 def name @name end |
#source_lang ⇒ Object (readonly)
Returns the value of attribute source_lang.
7 8 9 |
# File 'lib/txdb/table.rb', line 7 def source_lang @source_lang end |
Instance Method Details
#db ⇒ Object
16 17 18 |
# File 'lib/txdb/table.rb', line 16 def db database.db.from(name) end |
#read_content ⇒ Object
24 25 26 27 28 |
# File 'lib/txdb/table.rb', line 24 def read_content YAML.dump( database.backend.read_content_from(self) ) end |
#resource ⇒ Object
20 21 22 |
# File 'lib/txdb/table.rb', line 20 def resource @resource ||= Txdb::TxResource.from_table(self) end |
#write_content(content, locale) ⇒ Object
30 31 32 33 34 |
# File 'lib/txdb/table.rb', line 30 def write_content(content, locale) database.backend.write_content_to( self, YAML.load(content), locale ) end |