class Redata::Relation

Attributes

category[RW]
dir[RW]
file[RW]
key[RW]
name[RW]
type[RW]

Public Class Methods

new(category, name, setting) click to toggle source
# File lib/redata/relation.rb, line 4
def initialize(category, name, setting)
        @category = category
        @name = name
        @key = setting[:as] || @name.to_sym
        @file = setting[:file] || @name
        @dir = setting[:dir] || (@category == :main ? nil : @category.to_s)
end

Public Instance Methods

global_key() click to toggle source
# File lib/redata/relation.rb, line 12
def global_key
        @category == :main ? @key : "#{@category}_#{@key}".to_sym
end
query_file() click to toggle source
# File lib/redata/relation.rb, line 21
def query_file
        query_file = RED.root.join 'query', 'sources'
        query_file = query_file.join @dir if @dir
        query_file = query_file.join "#{@file}.red.sql"
        query_file
end
source_name() click to toggle source
# File lib/redata/relation.rb, line 16
          def source_name
postfix = RED.identify ? "_#{RED.identify}" : ""
                  @category == :main ? "#{@name}#{postfix}" : "#{@category}_#{@name}#{postfix}"
          end
tmp_exec_file() click to toggle source
# File lib/redata/relation.rb, line 32
def tmp_exec_file
        self.tmp_file_dir.join "exec.sql"
end
tmp_file_dir() click to toggle source
# File lib/redata/relation.rb, line 28
def tmp_file_dir
        RED.root.join 'tmp', "#{@category}_#{@name}"
end
tmp_mkdir() click to toggle source
# File lib/redata/relation.rb, line 36
def tmp_mkdir
        Dir.mkdir self.tmp_file_dir unless self.tmp_file_dir.exist?
end
tmp_rmdir() click to toggle source
# File lib/redata/relation.rb, line 40
def tmp_rmdir
        FileUtils.rm_r self.tmp_file_dir if !RED.keep_tmp? && self.tmp_file_dir.exist?
end