diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-19 19:38:36 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-05-19 19:38:36 -0700 |
commit | 2d021c641ab8c9215df863531cfb0d8ff8b9554a (patch) | |
tree | da95d1423997ade3b000b0c210c44c2936c87f57 /lib/arel/relations | |
parent | 9e5ee49ec55b9cb1c2b4444dee58f3dfaefc7c7e (diff) | |
download | rails-2d021c641ab8c9215df863531cfb0d8ff8b9554a.tar.gz rails-2d021c641ab8c9215df863531cfb0d8ff8b9554a.tar.bz2 rails-2d021c641ab8c9215df863531cfb0d8ff8b9554a.zip |
removed more boiler-plate
Diffstat (limited to 'lib/arel/relations')
-rw-r--r-- | lib/arel/relations/operations/join.rb | 2 | ||||
-rw-r--r-- | lib/arel/relations/utilities/aggregation.rb | 11 | ||||
-rw-r--r-- | lib/arel/relations/utilities/nil.rb | 6 | ||||
-rw-r--r-- | lib/arel/relations/writes/delete.rb | 10 | ||||
-rw-r--r-- | lib/arel/relations/writes/insert.rb | 9 | ||||
-rw-r--r-- | lib/arel/relations/writes/update.rb | 11 |
6 files changed, 12 insertions, 37 deletions
diff --git a/lib/arel/relations/operations/join.rb b/lib/arel/relations/operations/join.rb index 01fa6da255..243a0289c7 100644 --- a/lib/arel/relations/operations/join.rb +++ b/lib/arel/relations/operations/join.rb @@ -5,7 +5,7 @@ module Arel delegate :engine, :name, :to => :relation1 hash_on :relation1 - def initialize(join_sql, relation1, relation2 = Nil.new, *predicates) + def initialize(join_sql, relation1, relation2 = Nil.instance, *predicates) @join_sql, @relation1, @relation2, @predicates = join_sql, relation1, relation2, predicates end diff --git a/lib/arel/relations/utilities/aggregation.rb b/lib/arel/relations/utilities/aggregation.rb index 66150bff0a..9f5ead8f86 100644 --- a/lib/arel/relations/utilities/aggregation.rb +++ b/lib/arel/relations/utilities/aggregation.rb @@ -1,11 +1,9 @@ module Arel class Aggregation < Compound + attributes :relation + deriving :initialize, :== include Recursion::BaseCase - def initialize(relation) - @relation = relation - end - def wheres [] end @@ -21,11 +19,6 @@ module Arel def name relation.name + '_aggregation' end - - def ==(other) - Aggregation === other and - self.relation == other.relation - end end class Relation diff --git a/lib/arel/relations/utilities/nil.rb b/lib/arel/relations/utilities/nil.rb index 2dcfb47233..2b8dc570f8 100644 --- a/lib/arel/relations/utilities/nil.rb +++ b/lib/arel/relations/utilities/nil.rb @@ -1,10 +1,8 @@ module Arel class Nil < Relation + include Singleton + def table_sql(formatter = nil); '' end def name; '' end - - def ==(other) - Nil === other - end end end
\ No newline at end of file diff --git a/lib/arel/relations/writes/delete.rb b/lib/arel/relations/writes/delete.rb index 2eaad6d1da..e72679c4d6 100644 --- a/lib/arel/relations/writes/delete.rb +++ b/lib/arel/relations/writes/delete.rb @@ -1,8 +1,7 @@ module Arel class Deletion < Compound - def initialize(relation) - @relation = relation - end + attributes :relation + deriving :initialize, :== def to_sql(formatter = nil) [ @@ -16,10 +15,5 @@ module Arel def call(connection = engine.connection) connection.delete(to_sql) end - - def ==(other) - Deletion === other and - relation == other.relation - end end end
\ No newline at end of file diff --git a/lib/arel/relations/writes/insert.rb b/lib/arel/relations/writes/insert.rb index a1c4c93de5..0545d7faa3 100644 --- a/lib/arel/relations/writes/insert.rb +++ b/lib/arel/relations/writes/insert.rb @@ -1,6 +1,7 @@ module Arel class Insert < Compound - attr_reader :record + attributes :relation, :record + deriving :== def initialize(relation, record) @relation, @record = relation, record.bind(relation) @@ -18,11 +19,5 @@ module Arel def call(connection = engine.connection) connection.insert(to_sql) end - - def ==(other) - Insert === other and - relation == other.relation and - record == other.record - end end end
\ No newline at end of file diff --git a/lib/arel/relations/writes/update.rb b/lib/arel/relations/writes/update.rb index 760f4e931f..18b7ad9de1 100644 --- a/lib/arel/relations/writes/update.rb +++ b/lib/arel/relations/writes/update.rb @@ -1,7 +1,8 @@ module Arel class Update < Compound - attr_reader :assignments - + attributes :relation, :assignments + deriving :== + def initialize(relation, assignments) @relation, @assignments = relation, assignments.bind(relation) end @@ -20,11 +21,5 @@ module Arel def call(connection = engine.connection) connection.update(to_sql) end - - def ==(other) - Update === other and - relation == other.relation and - assignments == other.assignments - end end end
\ No newline at end of file |