Module: Lore
- Defined in:
- lib/lore/clause.rb,
lib/lore.rb,
lib/lore/bits.rb,
lib/lore/model.rb,
lib/lore/query.rb,
lib/lore/migration.rb,
lib/lore/cache/bits.rb,
lib/lore/model/aspect.rb,
lib/lore/model/filters.rb,
lib/lore/model/prepare.rb,
lib/lore/model/mockable.rb,
lib/lore/cache/cacheable.rb,
lib/lore/query_shortcuts.rb,
lib/lore/adapters/context.rb,
lib/lore/cache/file_index.rb,
lib/lore/model/polymorphic.rb,
lib/lore/gui/form_generator.rb,
lib/lore/model/associations.rb,
lib/lore/model/model_factory.rb,
lib/lore/model/model_instance.rb,
lib/lore/model/table_accessor.rb,
lib/lore/cache/cached_entities.rb,
lib/lore/model/model_shortcuts.rb,
lib/lore/adapters/postgres/types.rb,
lib/lore/cache/mmap_entity_cache.rb,
lib/lore/exceptions/unknown_type.rb,
lib/lore/strategies/table_delete.rb,
lib/lore/strategies/table_insert.rb,
lib/lore/strategies/table_select.rb,
lib/lore/strategies/table_update.rb,
lib/lore/adapters/postgres/result.rb,
lib/lore/exceptions/invalid_field.rb,
lib/lore/model/attribute_settings.rb,
lib/lore/cache/memory_entity_cache.rb,
lib/lore/validation/type_validator.rb,
lib/lore/adapters/postgres-pr/types.rb,
lib/lore/exceptions/cache_exception.rb,
lib/lore/adapters/postgres-pr/result.rb,
lib/lore/cache/abstract_entity_cache.rb,
lib/lore/cache/memcache_entity_cache.rb,
lib/lore/adapters/postgres/connection.rb,
lib/lore/cache/mmap_entity_cache_bork.rb,
lib/lore/exceptions/database_exception.rb,
lib/lore/exceptions/validation_failure.rb,
lib/lore/exceptions/ambiguous_attribute.rb,
lib/lore/validation/parameter_validator.rb,
lib/lore/adapters/postgres-pr/connection.rb
Overview
Defined Under Namespace
Modules: Aspect, Cache, Exceptions, GUI, Mockable, Model_Instance, Model_Shortcuts, Polymorphic_Class_Methods, Polymorphic_Instance_Methods, Prepare, Prepare_Class_Methods, Query_Shortcuts, Validation
Classes: Associations, Attribute_Hash, Attribute_Settings, Clause, Clause_Parser, Connection, Connection_Error, Connection_Pool, Context, Delete_Query, Filters, Insert_Query, Join, Migration, Model, Model_Factory, Refined_Delete, Refined_Query, Refined_Select, Refined_Update, Result, Select_Query, Table_Accessor, Table_Delete, Table_Insert, Table_Select, Table_Update, Type, Type_Filters, Update_Query
Constant Summary
collapse
- VERSION =
'0.9.2'
- PG_BOOL =
16
- PG_BYTEA =
17
- PG_SMALLINT =
21
- PG_CHAR =
18
- PG_INT =
23
- PG_TEXT =
25
- PG_FLOAT =
701
- 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_FLOAT => 'float',
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
71
72
73
|
# File 'lib/lore.rb', line 71
def self.add_login_data(login_hash)
@logins.update(login_hash)
end
|
.cache_enabled? ⇒ Boolean
111
112
113
|
# File 'lib/lore.rb', line 111
def self.cache_enabled?
@cache_entities
end
|
.disable_cache ⇒ Object
103
104
105
|
# File 'lib/lore.rb', line 103
def self.disable_cache
@cache_entities = false
end
|
.disable_logging ⇒ Object
50
51
52
53
|
# File 'lib/lore.rb', line 50
def self.disable_logging
@logging_enabled = false
Lore.logger.level = Logger::ERROR
end
|
.disable_query_log ⇒ Object
61
62
63
|
# File 'lib/lore.rb', line 61
def self.disable_query_log
@log_queries = false
end
|
.enable_cache ⇒ Object
107
108
109
|
# File 'lib/lore.rb', line 107
def self.enable_cache
@cache_entities = true
end
|
.enable_logging ⇒ Object
54
55
56
57
|
# File 'lib/lore.rb', line 54
def self.enable_logging
@logging_enabled = true
Lore.logger.level = Logger::DEBUG
end
|
.enable_query_log ⇒ Object
58
59
60
|
# File 'lib/lore.rb', line 58
def self.enable_query_log
@log_queries = true
end
|
.log_queries? ⇒ Boolean
46
47
48
|
# File 'lib/lore.rb', line 46
def self.log_queries?
@log_queries && @logging_enabled
end
|
18
19
20
|
# File 'lib/lore.rb', line 18
def self.logfile
@logfile
end
|
.logfile=(file) ⇒ Object
24
25
26
27
|
# File 'lib/lore.rb', line 24
def self.logfile=(file)
@logger = Logger.new(file)
@query_logger = Logger.new(file)
end
|
31
32
33
|
# File 'lib/lore.rb', line 31
def self.logger
@logger
end
|
.logging_disabled? ⇒ Boolean
64
65
66
|
# File 'lib/lore.rb', line 64
def self.logging_disabled?
!@logging_enabled
end
|
.on_connect_commands ⇒ Object
115
116
117
|
# File 'lib/lore.rb', line 115
def self.on_connect_commands()
"set client_encoding to Unicode; set datestyle to 'European'"
end
|
.parse_field_value(value) ⇒ Object
69
70
71
72
73
74
75
76
77
|
# File 'lib/lore/clause.rb', line 69
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
99
100
101
|
# File 'lib/lore.rb', line 99
def self.pass_for(dbname)
@logins[dbname.to_s][1]
end
|
75
76
77
|
# File 'lib/lore.rb', line 75
def self.path
File.expand_path(File.dirname(__FILE__)) + '/'
end
|
82
83
84
|
# File 'lib/lore.rb', line 82
def self.pg_port
@pg_port
end
|
.pg_port=(p) ⇒ Object
88
89
90
|
# File 'lib/lore.rb', line 88
def self.pg_port=(p)
@pg_port = p
end
|
.pg_server ⇒ Object
79
80
81
|
# File 'lib/lore.rb', line 79
def self.pg_server
@pg_server
end
|
.pg_server=(s) ⇒ Object
85
86
87
|
# File 'lib/lore.rb', line 85
def self.pg_server=(s)
@pg_server = s
end
|
.query_logfile ⇒ Object
21
22
23
|
# File 'lib/lore.rb', line 21
def self.query_logfile
@query_logfile
end
|
.query_logfile=(file) ⇒ Object
28
29
30
|
# File 'lib/lore.rb', line 28
def self.query_logfile=(file)
@query_logger = Logger.new(file)
end
|
.query_logger ⇒ Object
34
35
36
|
# File 'lib/lore.rb', line 34
def self.query_logger
@query_logger
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
68
69
70
|
# File 'lib/lore.rb', line 68
def self.set_login_data(login_hash)
@logins = login_hash
end
|
.user_for(dbname) ⇒ Object
92
93
94
95
96
97
98
|
# File 'lib/lore.rb', line 92
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
|