Class: RailsNewsfeed::FeedTable
- Inherits:
-
Object
- Object
- RailsNewsfeed::FeedTable
- Defined in:
- lib/rails_newsfeed/feed_table.rb
Class Method Summary collapse
-
.all ⇒ Object
gets all feed tables.
-
.create(tbl_class) ⇒ Object
adds table.
-
.delete(tbl_class) ⇒ Object
removes table.
-
.schema ⇒ Object
gets schema DO NOT override this method unless you know what you are doing.
-
.table_name ⇒ Object
gets table name.
Class Method Details
.all ⇒ Object
gets all feed tables
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rails_newsfeed/feed_table.rb', line 25 def self.all items = [] Connection.select(table_name).each do |r| cons = r['table_class'].safe_constantize next unless cons ins = cons.new items.push(ins) if ins end items end |
.create(tbl_class) ⇒ Object
adds table
15 16 17 |
# File 'lib/rails_newsfeed/feed_table.rb', line 15 def self.create(tbl_class) Connection.insert(table_name, schema, table_class: tbl_class) end |
.delete(tbl_class) ⇒ Object
removes table
20 21 22 |
# File 'lib/rails_newsfeed/feed_table.rb', line 20 def self.delete(tbl_class) Connection.delete(table_name, schema, table_class: tbl_class) end |
.schema ⇒ Object
gets schema DO NOT override this method unless you know what you are doing
10 11 12 |
# File 'lib/rails_newsfeed/feed_table.rb', line 10 def self.schema { table_class: :text } end |
.table_name ⇒ Object
gets table name
4 5 6 |
# File 'lib/rails_newsfeed/feed_table.rb', line 4 def self.table_name 'feed_table' end |