Module: Lore

Defined in:
lib/lore.rb,
lib/lore/bits.rb,
lib/lore/model.rb,
lib/lore/types.rb,
lib/lore/aspect.rb,
lib/lore/clause.rb,
lib/lore/result.rb,
lib/lore/gui/form.rb,
lib/lore/migration.rb,
lib/lore/cache/bits.rb,
lib/lore/connection.rb,
lib/lore/validation.rb,
lib/lore/model_factory.rb,
lib/lore/table_deleter.rb,
lib/lore/table_updater.rb,
lib/lore/table_accessor.rb,
lib/lore/table_inserter.rb,
lib/lore/table_instance.rb,
lib/lore/table_selector.rb,
lib/lore/cache/cacheable.rb,
lib/lore/model_shortcuts.rb,
lib/lore/query_shortcuts.rb,
lib/lore/cache/file_index.rb,
lib/lore/gui/erb_template.rb,
lib/lore/gui/form_element.rb,
lib/lore/validation/reason.rb,
lib/lore/behaviours/movable.rb,
lib/lore/gui/form_generator.rb,
lib/lore/validation/message.rb,
lib/lore/behaviours/lockable.rb,
lib/lore/behaviours/versioned.rb,
lib/lore/cache/cached_entities.rb,
lib/lore/cache/mmap_entity_cache.rb,
lib/lore/exception/cache_exception.rb,
lib/lore/validation/type_validator.rb,
lib/lore/exception/unknown_typecode.rb,
lib/lore/cache/abstract_entity_cache.rb,
lib/lore/exception/invalid_parameter.rb,
lib/lore/exception/ambiguous_attribute.rb,
lib/lore/validation/parameter_validator.rb,
lib/lore/exception/invalid_klass_parameters.rb

Defined Under Namespace

Modules: Aspect, Behaviours, Cache, Exception, GUI, Migration, Model_Shortcuts, Query_Shortcuts, Table_Deleter, Table_Inserter, Table_Instance, Table_Selector, Table_Updater, Validation Classes: Attribute_Hash, Clause, Clause_Parser, Connection, Connection_Error, Connection_Pool, Context, Join, Model, Model_Factory, Refined_Delete, Refined_Query, Refined_Select, Refined_Update, Result, Table_Accessor, Type

Constant Summary collapse

VERSION =
'0.4.6'
PG_BOOL =
16
PG_BYTEA =
17
PG_SMALLINT =
21
PG_CHAR =
18
PG_INT =
23
PG_TEXT =
25
PG_CHARACTER =
1042
PG_VARCHAR =
1043
PG_TIME =
1083
PG_TIMESTAMP_TIMEZONE =
1184
PG_TIMESTAMP =
1114
PG_DATE =
1082
PG_VCHAR_LIST =
1015
PG_DECIMAL =
1700
TYPE_NAMES =
{ 
  PG_BYTEA               => 'bytea',
  PG_BOOL                => 'boolean',
  PG_SMALLINT            => 'small int',
  PG_CHAR                => 'char',
  PG_INT                 => 'integer',
  PG_TEXT                => 'text',
  PG_CHARACTER           => 'character',
  PG_VARCHAR             => 'character varying(1000)',
  PG_TIME                => 'time',
  PG_TIMESTAMP_TIMEZONE  => 'timestamp with timezone',
  PG_TIMESTAMP           => 'timestamp',
  PG_DATE                => 'data',
  PG_VCHAR_LIST          => 'character varying[]', 
  PG_DECIMAL             => 'decimal'
}

Class Method Summary collapse

Class Method Details

.add_login_data(login_hash) ⇒ Object



40
41
42
# File 'lib/lore.rb', line 40

def self.()
  @logins.update()
end

.cache_enabled?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/lore.rb', line 83

def self.cache_enabled? 
  @cache_entities
end

.disable_cacheObject



75
76
77
# File 'lib/lore.rb', line 75

def self.disable_cache
  @cache_entities = false
end

.enable_cacheObject



79
80
81
# File 'lib/lore.rb', line 79

def self.enable_cache
  @cache_entities = true
end

.log(&log_block) ⇒ Object



20
21
22
23
# File 'lib/lore.rb', line 20

def self.log(&log_block)
  return if Lore.logging_disabled?  
  Lore.logger.debug(&log_block)
end

.log_queries?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/lore.rb', line 25

def self.log_queries? 
  true
end

.logfileObject



9
10
11
# File 'lib/lore.rb', line 9

def self.logfile
  @logfile
end

.logfile=(file) ⇒ Object



12
13
14
# File 'lib/lore.rb', line 12

def self.logfile=(file)
  @logger = Logger.new(file)
end

.loggerObject



15
16
17
# File 'lib/lore.rb', line 15

def self.logger
  @logger
end

.logging_disabled?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/lore.rb', line 28

def self.logging_disabled? 
  false
end

.on_connect_commandsObject



87
88
89
# File 'lib/lore.rb', line 87

def self.on_connect_commands()
  "set client_encoding to Unicode; set datestyle to 'European'"
end

.parse_field_value(value) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/lore/clause.rb', line 15

def self.parse_field_value(value)
    if value.instance_of? Clause then
      value = value.field_name
    else 
      value = value.to_s.lore_escape
      value = '\'' << value << '\''
    end
    value
end

.pass_for(dbname) ⇒ Object



71
72
73
# File 'lib/lore.rb', line 71

def self.pass_for(dbname)
  @logins[dbname.to_s][1].to_s
end

.pathObject



44
45
46
# File 'lib/lore.rb', line 44

def self.path
  File.expand_path(File.dirname(__FILE__)) + '/'
end

.pg_portObject



54
55
56
# File 'lib/lore.rb', line 54

def self.pg_port
  @pg_port
end

.pg_port=(p) ⇒ Object



60
61
62
# File 'lib/lore.rb', line 60

def self.pg_port=(p)
  @pg_port = p
end

.pg_serverObject



51
52
53
# File 'lib/lore.rb', line 51

def self.pg_server
  @pg_server
end

.pg_server=(s) ⇒ Object



57
58
59
# File 'lib/lore.rb', line 57

def self.pg_server=(s)
  @pg_server = s
end

.resolve_passed_value(values, table_name, attrib_name) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/lore/bits.rb', line 4

def self.resolve_passed_value(values, table_name, attrib_name)
  return { :value => values[attrib_name].to_s, :field => attrib_name }
  idx = attrib_name.to_s.length
  value = nil
  while value.nil? && idx > 1 do 
    name_part = attrib_name.to_s[0..idx]
    value = values[name_part]
    if value == '' then 
      name_part = table_name + '.' << name_part
      value = values[name_part]
    end

    idx -= 1
  end
  { :value => value, :field => name_part }
end

.set_login_data(login_hash) ⇒ Object



37
38
39
# File 'lib/lore.rb', line 37

def self.()
  @logins = 
end

.user_for(dbname) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/lore.rb', line 64

def self.user_for(dbname)
  begin
    @logins[dbname.to_s][0].to_s
  rescue ::Exception => excep
    raise ::Exception.new('Unable to resolve user for database ' << dbname.inspect)
  end
end