class Redata::Schema
Public Class Methods
new()
click to toggle source
# File lib/redata/schema.rb, line 3 def initialize @category = :main @order = [] @index = {} end
Public Instance Methods
category(prefix, &block)
click to toggle source
# File lib/redata/schema.rb, line 13 def category(prefix, &block) @category = prefix self.instance_eval &block @category = :main end
category_configs(category, types=[])
click to toggle source
# File lib/redata/schema.rb, line 41 def category_configs(category, types=[]) res = [] @order.each do |global_key| config = @index[global_key] res.push config if (!category || config.category == category) && (types.empty? || types.include?(config.type)) end res end
config(&block)
click to toggle source
# File lib/redata/schema.rb, line 9 def config(&block) self.instance_eval &block end
config_with(key)
click to toggle source
# File lib/redata/schema.rb, line 35 def config_with(key) config = @index[key] return nil unless config config end
export(target, setting={})
click to toggle source
# File lib/redata/schema.rb, line 27 def export(target, setting={}) register target, :export, setting end
insert(target, setting={})
click to toggle source
# File lib/redata/schema.rb, line 31 def insert(target, setting={}) register target, :insert, setting end
table(table, setting={})
click to toggle source
# File lib/redata/schema.rb, line 23 def table(table, setting={}) register table, :table, setting end
view(view, setting={})
click to toggle source
# File lib/redata/schema.rb, line 19 def view(view, setting={}) register view, :view, setting end
Private Instance Methods
register(name, type, setting={})
click to toggle source
# File lib/redata/schema.rb, line 51 def register(name, type, setting={}) cla = Redata.const_get type.capitalize relation = cla.new @category, name, setting if @index[relation.global_key] Log.log "in #{caller.first}" Log.error! "ERROR: Duplicated view alias '#{global_key}'" end @index[relation.global_key] = relation @order.push relation.global_key end