223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
# File 'lib/pg_graph/reflector.rb', line 223
def self.default_reflections
@default_reflections ||= begin
initializers = [
{"match"=>"/parent_id/", "that"=>"child"},
{"match"=>"/child_id/", "that"=>"parent"},
{"match"=>"/parent_(\\w+)_id/", "that"=>"child_$1"},
{"match"=>"/child_(\\w+)_id/", "that"=>"parent_$1"},
{"match"=>"kind", "this"=>"kind", "that"=>"$$"},
{"match"=>"/(\\w+)_kind/", "this"=>"$1", "that"=>"$$"},
{"match"=>"/(\\w+)_by_id/", "this"=>"$1_by", "that"=>"$1_$$", pluralize: true},
{"match"=>"/(\\w+)_id/", "this"=>"$1", "that"=>"$$", multi: false},
{"match"=>"/(\\w+)_id/", "this"=>"$1", "that"=>"$1_of", multi: true, pluralize: false},
{"match"=>"/(\\w+)/", "this"=>"$1", "that"=>"$$"},
]
initializers.map { |initializer|
Reflection.load_yaml initializer.merge(default_reflection: true)
}
end
end
|