Class: Groonga::Schema::ViewDefinition
- Inherits:
-
Object
- Object
- Groonga::Schema::ViewDefinition
- Defined in:
- lib/groonga/schema.rb
Overview
スキーマ定義時に create_view や #create_view からブロックに渡されてくる オブジェクト
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
ビューの名前.
Instance Method Summary collapse
-
#add(table) ⇒ Object
名前が table のテーブルをビューに追加する。.
- #context ⇒ Object
- #define ⇒ Object
-
#initialize(name, options) ⇒ ViewDefinition
constructor
A new instance of ViewDefinition.
Constructor Details
#initialize(name, options) ⇒ ViewDefinition
Returns a new instance of ViewDefinition.
1602 1603 1604 1605 1606 1607 1608 |
# File 'lib/groonga/schema.rb', line 1602 def initialize(name, ) @name = name @name = @name.to_s if @name.is_a?(Symbol) @tables = [] () = end |
Instance Attribute Details
#name ⇒ Object (readonly)
ビューの名前
1599 1600 1601 |
# File 'lib/groonga/schema.rb', line 1599 def name @name end |
Instance Method Details
#add(table) ⇒ Object
名前が table のテーブルをビューに追加する。
1634 1635 1636 1637 1638 |
# File 'lib/groonga/schema.rb', line 1634 def add(table) table = table.to_s if table.is_a?(Symbol) @tables << table self end |
#context ⇒ Object
1641 1642 1643 |
# File 'lib/groonga/schema.rb', line 1641 def context [:context] || Groonga::Context.default end |
#define ⇒ Object
1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 |
# File 'lib/groonga/schema.rb', line 1611 def define view = context[@name] if [:change] raise TableNotExists.new(@name) if view.nil? else if view and [:force] view.remove view = nil end view ||= Groonga::View.create() end @tables.each do |table| unless table.is_a?(Groonga::Table) table_name = table table = context[table_name] raise TableNotExists.new(table_name) if table.nil? end view.add_table(table) end view end |