dependency to methodphitamine removed.

master
Denis Knauf 2011-11-30 13:52:19 +01:00
parent 2b3922e158
commit edcc68a4ed
3 changed files with 10 additions and 8 deletions

View File

@ -15,7 +15,6 @@ begin
gem.add_dependency 'activerecord' gem.add_dependency 'activerecord'
gem.add_dependency 'activesupport' gem.add_dependency 'activesupport'
gem.add_dependency 'json' gem.add_dependency 'json'
gem.add_dependency 'methodphitamine'
end end
Jeweler::GemcutterTasks.new Jeweler::GemcutterTasks.new
rescue LoadError rescue LoadError

View File

@ -152,10 +152,10 @@ class SmqlToAR
@model = model @model = model
@last_model = nil @last_model = nil
*@path, @col = *Array.wrap( col). *@path, @col = *Array.wrap( col).
collect( &it.to_s.split( /[.\/]/)). collect {|x| x.to_s.split /[.\/]/ }.
flatten. flatten.
collect( &Col.method( :new)). collect( &Col.method( :new)).
reject( &it===:self) reject {|x| x === :self }
end end
def last_model def last_model

View File

@ -100,7 +100,7 @@ class SmqlToAR
# Passt das Object, die Klasse instanzieren. # Passt das Object, die Klasse instanzieren.
def try_parse model, cols, op, val def try_parse model, cols, op, val
#p :class => self, :self => name, :try_parse => op, :cols => cols, :with => self::Operator, :value => val, :expected => self::Expected, :model => model.name #p :class => self, :self => name, :try_parse => op, :cols => cols, :with => self::Operator, :value => val, :expected => self::Expected, :model => model.name
new model, cols, val if self::Operator === op and self::Expected.any?( &it === val) new model, cols, val if self::Operator === op and self::Expected.any? {|x| x === val}
end end
def inspect def inspect
@ -225,7 +225,7 @@ class SmqlToAR
# { 'articles=>' => [ { id: 1 }, { id: 2 } ] } # { 'articles=>' => [ { id: 1 }, { id: 2 } ] }
class EqualJoin <Condition class EqualJoin <Condition
Operator = '=>' Operator = '=>'
Expected = [Hash, lambda {|x| x.kind_of?( Array) and x.all?( &it.kind_of?( Hash))}] Expected = [Hash, lambda {|x| x.kind_of?( Array) and x.all? {|y| y.kind_of?( Hash) }}]
def initialize *pars def initialize *pars
super( *pars) super( *pars)
@ -255,7 +255,10 @@ class SmqlToAR
col.joins.each {|j, m| builder.joins table+j, m } col.joins.each {|j, m| builder.joins table+j, m }
builder.joins t, model builder.joins t, model
b4 = b3.new( b2) b4 = b3.new( b2)
sub.each {|i| i.collect( &it.build( And.new( b4), t)) } sub.each do |i|
b5 = And.new b4
i.collect {|j| j.build b5, t }
end
end end
self self
end end
@ -293,7 +296,7 @@ class SmqlToAR
t = table+col.to_a t = table+col.to_a
builder.sub_joins t, col, *sub[0..1] builder.sub_joins t, col, *sub[0..1]
#ap sub: sub[2..-1] #ap sub: sub[2..-1]
sub[2..-1].each &it.build( builder, t) sub[2..-1].each {|x| x.build builder, t }
end end
self self
end end
@ -345,7 +348,7 @@ class SmqlToAR
class <<self class <<self
def try_parse model, func, args def try_parse model, func, args
self.new model, func, args if self::Name === func and self::Expected.any?( &it === args) self.new model, func, args if self::Name === func and self::Expected.any? {|x| x === args }
end end
def inspect def inspect