lafcadio 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/lafcadio.rb +1 -1
- data/lib/lafcadio.rb~ +1 -1
- data/lib/lafcadio/domain.rb +16 -7
- data/lib/lafcadio/domain.rb~ +9 -0
- data/lib/lafcadio/mock.rb +7 -3
- data/lib/lafcadio/mock.rb~ +1 -1
- data/lib/lafcadio/objectStore.rb +6 -9
- data/lib/lafcadio/objectStore.rb~ +3 -7
- data/lib/lafcadio/query.rb~ +8 -6
- data/lib/lafcadio/util.rb +4 -0
- data/lib/lafcadio/util.rb~ +11 -8
- metadata +5 -4
data/lib/lafcadio.rb
CHANGED
data/lib/lafcadio.rb~
CHANGED
data/lib/lafcadio/domain.rb
CHANGED
@@ -278,6 +278,13 @@ module Lafcadio
|
|
278
278
|
unless class_fields
|
279
279
|
@@class_fields[self] = self.get_class_fields
|
280
280
|
class_fields = @@class_fields[self]
|
281
|
+
class_fields.each do |class_field|
|
282
|
+
begin
|
283
|
+
undef_method class_field.name.to_sym
|
284
|
+
rescue NameError
|
285
|
+
# not defined globally or in an included Module, skip it
|
286
|
+
end
|
287
|
+
end
|
281
288
|
end
|
282
289
|
class_fields
|
283
290
|
end
|
@@ -288,13 +295,15 @@ module Lafcadio
|
|
288
295
|
class_fields = [ @@pk_fields[self] ]
|
289
296
|
@@class_fields[self] = class_fields
|
290
297
|
end
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
+
unless class_fields.any? { |cf| cf.name == name }
|
299
|
+
att_hash['name'] = name
|
300
|
+
field = field_class.instantiate_with_parameters( self, att_hash )
|
301
|
+
att_hash.each { |field_name, value|
|
302
|
+
setter = field_name + '='
|
303
|
+
field.send( setter, value ) if field.respond_to?( setter )
|
304
|
+
}
|
305
|
+
class_fields << field
|
306
|
+
end
|
298
307
|
end
|
299
308
|
|
300
309
|
def self.dependent_classes #:nodoc:
|
data/lib/lafcadio/domain.rb~
CHANGED
@@ -278,6 +278,13 @@ module Lafcadio
|
|
278
278
|
unless class_fields
|
279
279
|
@@class_fields[self] = self.get_class_fields
|
280
280
|
class_fields = @@class_fields[self]
|
281
|
+
class_fields.each do |class_field|
|
282
|
+
begin
|
283
|
+
undef_method class_field.name.to_sym
|
284
|
+
rescue NameError
|
285
|
+
# not defined globally or in an included Module, skip it
|
286
|
+
end
|
287
|
+
end
|
281
288
|
end
|
282
289
|
class_fields
|
283
290
|
end
|
@@ -330,6 +337,8 @@ module Lafcadio
|
|
330
337
|
def self.get_class_fields
|
331
338
|
if self.methods( false ).include?( 'get_class_fields' )
|
332
339
|
[ @@pk_fields[ self ] ]
|
340
|
+
elsif abstract_subclasses.include?( self )
|
341
|
+
[]
|
333
342
|
else
|
334
343
|
xmlParser = try_load_xml_parser
|
335
344
|
if xmlParser
|
data/lib/lafcadio/mock.rb
CHANGED
@@ -74,10 +74,14 @@ module Lafcadio
|
|
74
74
|
|
75
75
|
def group_query( query )
|
76
76
|
if query.class == Query::Max
|
77
|
-
|
78
|
-
|
77
|
+
dobjs_by_pk_id = @objects[query.domain_class]
|
78
|
+
if dobjs_by_pk_id
|
79
|
+
dobjs = dobjs_by_pk_id.values.sort_by { |dobj|
|
80
|
+
dobj.send( query.field_name )
|
81
|
+
}
|
82
|
+
[ dobjs.last.send( query.field_name ) ]
|
79
83
|
else
|
80
|
-
|
84
|
+
[ nil ]
|
81
85
|
end
|
82
86
|
end
|
83
87
|
end
|
data/lib/lafcadio/mock.rb~
CHANGED
data/lib/lafcadio/objectStore.rb
CHANGED
@@ -11,9 +11,10 @@ module Lafcadio
|
|
11
11
|
|
12
12
|
attr_reader :commit_type, :db_object
|
13
13
|
|
14
|
-
def initialize(db_object, dbBridge)
|
14
|
+
def initialize(db_object, dbBridge, cache)
|
15
15
|
@db_object = db_object
|
16
16
|
@dbBridge = dbBridge
|
17
|
+
@cache = cache
|
17
18
|
@objectStore = ObjectStore.get_object_store
|
18
19
|
@commit_type = nil
|
19
20
|
end
|
@@ -28,6 +29,7 @@ module Lafcadio
|
|
28
29
|
unless @db_object.pk_id
|
29
30
|
@db_object.pk_id = @dbBridge.last_pk_id_inserted
|
30
31
|
end
|
32
|
+
@cache.update_after_commit self
|
31
33
|
@db_object.post_commit_trigger
|
32
34
|
end
|
33
35
|
|
@@ -129,12 +131,8 @@ module Lafcadio
|
|
129
131
|
|
130
132
|
def group_query( query )
|
131
133
|
execute_select( query.to_sql )[0].collect { |val|
|
132
|
-
|
133
|
-
|
134
|
-
a_field.value_from_sql( val )
|
135
|
-
else
|
136
|
-
val.to_i
|
137
|
-
end
|
134
|
+
a_field = query.domain_class.get_field( query.field_name )
|
135
|
+
a_field.value_from_sql( val )
|
138
136
|
}
|
139
137
|
end
|
140
138
|
|
@@ -540,9 +538,8 @@ module Lafcadio
|
|
540
538
|
end
|
541
539
|
|
542
540
|
def commit( db_object )
|
543
|
-
committer = Committer.new db_object, @dbBridge
|
541
|
+
committer = Committer.new db_object, @dbBridge, self
|
544
542
|
committer.execute
|
545
|
-
update_after_commit( committer )
|
546
543
|
end
|
547
544
|
|
548
545
|
# Flushes a domain object.
|
@@ -129,12 +129,8 @@ module Lafcadio
|
|
129
129
|
|
130
130
|
def group_query( query )
|
131
131
|
execute_select( query.to_sql )[0].collect { |val|
|
132
|
-
|
133
|
-
|
134
|
-
a_field.value_from_sql( val )
|
135
|
-
else
|
136
|
-
val.to_i
|
137
|
-
end
|
132
|
+
a_field = query.domain_class.get_field( query.field_name )
|
133
|
+
a_field.value_from_sql( val )
|
138
134
|
}
|
139
135
|
end
|
140
136
|
|
@@ -443,7 +439,7 @@ module Lafcadio
|
|
443
439
|
def get_db_bridge; @dbBridge; end
|
444
440
|
|
445
441
|
def get_field_name( domain_object )
|
446
|
-
domain_object.domain_class.basename.
|
442
|
+
domain_object.domain_class.basename.camel_case_to_underscore
|
447
443
|
end
|
448
444
|
|
449
445
|
def get_filtered(domain_class_name, searchTerm, fieldName = nil) #:nodoc:
|
data/lib/lafcadio/query.rb~
CHANGED
@@ -273,15 +273,17 @@ module Lafcadio
|
|
273
273
|
AND = 1
|
274
274
|
OR = 2
|
275
275
|
|
276
|
-
def initialize(*
|
277
|
-
if( [ AND, OR ].index(
|
278
|
-
@compoundType =
|
279
|
-
|
276
|
+
def initialize( *args )
|
277
|
+
if( [ AND, OR ].index( args.last) )
|
278
|
+
@compoundType = args.last
|
279
|
+
args.pop
|
280
280
|
else
|
281
281
|
@compoundType = AND
|
282
282
|
end
|
283
|
-
@conditions =
|
284
|
-
|
283
|
+
@conditions = args.map { |arg|
|
284
|
+
arg.respond_to?( :to_condition ) ? arg.to_condition : arg
|
285
|
+
}
|
286
|
+
@domain_class = @conditions[0].domain_class
|
285
287
|
end
|
286
288
|
|
287
289
|
def object_meets(anObj)
|
data/lib/lafcadio/util.rb
CHANGED
@@ -133,8 +133,12 @@ module Lafcadio
|
|
133
133
|
consonantYPattern = Regexp.new("([^aeiou])y$", Regexp::IGNORECASE)
|
134
134
|
if singular =~ consonantYPattern
|
135
135
|
singular.gsub consonantYPattern, '\1ies'
|
136
|
+
elsif singular =~ /^(.*)xis$/
|
137
|
+
$1 + 'xes'
|
136
138
|
elsif singular =~ /[xs]$/
|
137
139
|
singular + "es"
|
140
|
+
elsif singular =~ /(.*)tum$/
|
141
|
+
$1 + 'ta'
|
138
142
|
else
|
139
143
|
singular + "s"
|
140
144
|
end
|
data/lib/lafcadio/util.rb~
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'delegate'
|
2
|
+
require 'lafcadio/depend'
|
2
3
|
require 'singleton'
|
3
4
|
|
4
5
|
module Lafcadio
|
@@ -66,14 +67,16 @@ module Lafcadio
|
|
66
67
|
class ContextualService
|
67
68
|
def self.flush; Context.instance.set_resource( self, nil ); end
|
68
69
|
|
69
|
-
def self.method_missing(
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
70
|
+
def self.method_missing( symbol, *args )
|
71
|
+
method_name = symbol.id2name
|
72
|
+
target = nil
|
73
|
+
if method_name =~ /^get_(.*)/
|
74
|
+
target = :get_resource if $1.underscore_to_camel_case == basename
|
75
|
+
elsif method_name =~ /^set_(.*)/
|
76
|
+
target = :set_resource if $1.underscore_to_camel_case == basename
|
77
|
+
end
|
78
|
+
if target
|
79
|
+
Context.instance.send( target, self, *args )
|
77
80
|
else
|
78
81
|
super
|
79
82
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.6
|
3
3
|
specification_version: 1
|
4
4
|
name: lafcadio
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.6.
|
7
|
-
date: 2005-
|
6
|
+
version: 0.6.5
|
7
|
+
date: 2005-07-17
|
8
8
|
summary: Lafcadio is an object-relational mapping layer
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
|
-
author: Francis Hwang
|
12
11
|
email: sera@fhwang.net
|
13
12
|
homepage: http://lafcadio.rubyforge.org/
|
14
13
|
rubyforge_project:
|
@@ -29,6 +28,8 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
29
28
|
version: 0.0.0
|
30
29
|
version:
|
31
30
|
platform: ruby
|
31
|
+
authors:
|
32
|
+
- Francis Hwang
|
32
33
|
files:
|
33
34
|
- lib/lafcadio
|
34
35
|
- lib/lafcadio.rb
|