class Purview::Tables::Base
Attributes
columns[R]
database[R]
indices[R]
name[R]
opts[R]
Public Class Methods
new(name, opts={})
click to toggle source
# File lib/purview/tables/base.rb, line 6 def initialize(name, opts={}) @name = name.to_sym @opts = opts @database = database_opt @columns = Set.new.tap do |result| (default_columns + columns_opt).each do |column| column.table = self if result.add?(column) end end @indices = Set.new.tap do |result| (default_indices + indices_opt).each do |index| index.table = self if result.add?(index) end end end
Public Instance Methods
column_names()
click to toggle source
# File lib/purview/tables/base.rb, line 22 def column_names columns.map(&:name) end
columns_by_name()
click to toggle source
# File lib/purview/tables/base.rb, line 26 def columns_by_name columns.reduce({}) do |memo, column| memo[column.name] = column memo end end
columns_by_source_name()
click to toggle source
# File lib/purview/tables/base.rb, line 33 def columns_by_source_name columns.reduce({}) do |memo, column| memo[column.source_name] = column memo end end
database=(value)
click to toggle source
# File lib/purview/tables/base.rb, line 40 def database=(value) raise Purview::Exceptions::DatabaseAlreadyAssignedForTable.new(self) if database @database = value end
Private Instance Methods
columns_opt()
click to toggle source
# File lib/purview/tables/base.rb, line 52 def columns_opt opts[:columns] || [] end
database_opt()
click to toggle source
# File lib/purview/tables/base.rb, line 56 def database_opt opts[:database] end
default_columns()
click to toggle source
# File lib/purview/tables/base.rb, line 60 def default_columns [] end
default_indices()
click to toggle source
# File lib/purview/tables/base.rb, line 64 def default_indices [] end
indices_opt()
click to toggle source
# File lib/purview/tables/base.rb, line 68 def indices_opt opts[:indices] || [] end