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.7'
- 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
56
57
58
|
# File 'lib/lore.rb', line 56
def self.add_login_data(login_hash)
@logins.update(login_hash)
end
|
.cache_enabled? ⇒ Boolean
96
97
98
|
# File 'lib/lore.rb', line 96
def self.cache_enabled?
@cache_entities
end
|
.disable_cache ⇒ Object
88
89
90
|
# File 'lib/lore.rb', line 88
def self.disable_cache
@cache_entities = false
end
|
.disable_logging ⇒ Object
37
38
39
|
# File 'lib/lore.rb', line 37
def self.disable_logging
@logging_enabled = false
end
|
.disable_query_log ⇒ Object
46
47
48
|
# File 'lib/lore.rb', line 46
def self.disable_query_log
@log_queries = false
end
|
.enable_cache ⇒ Object
92
93
94
|
# File 'lib/lore.rb', line 92
def self.enable_cache
@cache_entities = true
end
|
.enable_logging ⇒ Object
40
41
42
|
# File 'lib/lore.rb', line 40
def self.enable_logging
@logging_enabled = true
end
|
.enable_query_log ⇒ Object
43
44
45
|
# File 'lib/lore.rb', line 43
def self.enable_query_log
@log_queries = true
end
|
.log(&log_block) ⇒ Object
.log_queries? ⇒ Boolean
33
34
35
|
# File 'lib/lore.rb', line 33
def self.log_queries?
@log_queries && @logging_enabled
end
|
.logfile ⇒ Object
17
18
19
|
# File 'lib/lore.rb', line 17
def self.logfile
@logfile
end
|
.logfile=(file) ⇒ Object
20
21
22
|
# File 'lib/lore.rb', line 20
def self.logfile=(file)
@logger = Logger.new(file)
end
|
.logger ⇒ Object
23
24
25
|
# File 'lib/lore.rb', line 23
def self.logger
@logger
end
|
.logging_disabled? ⇒ Boolean
49
50
51
|
# File 'lib/lore.rb', line 49
def self.logging_disabled?
!@logging_enabled
end
|
.on_connect_commands ⇒ Object
100
101
102
|
# File 'lib/lore.rb', line 100
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
84
85
86
|
# File 'lib/lore.rb', line 84
def self.pass_for(dbname)
@logins[dbname.to_s][1].to_s
end
|
.path ⇒ Object
60
61
62
|
# File 'lib/lore.rb', line 60
def self.path
File.expand_path(File.dirname(__FILE__)) + '/'
end
|
.pg_port ⇒ Object
67
68
69
|
# File 'lib/lore.rb', line 67
def self.pg_port
@pg_port
end
|
.pg_port=(p) ⇒ Object
73
74
75
|
# File 'lib/lore.rb', line 73
def self.pg_port=(p)
@pg_port = p
end
|
.pg_server ⇒ Object
64
65
66
|
# File 'lib/lore.rb', line 64
def self.pg_server
@pg_server
end
|
.pg_server=(s) ⇒ Object
70
71
72
|
# File 'lib/lore.rb', line 70
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
53
54
55
|
# File 'lib/lore.rb', line 53
def self.set_login_data(login_hash)
@logins = login_hash
end
|
.user_for(dbname) ⇒ Object
77
78
79
80
81
82
83
|
# File 'lib/lore.rb', line 77
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
|