Class: Phoenix::Relation

Inherits:
Object
  • Object
show all
Defined in:
lib/phoenix/relation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sql) ⇒ Relation

Returns a new instance of Relation.



7
8
9
# File 'lib/phoenix/relation.rb', line 7

def initialize(sql)
  @sql = sql
end

Instance Attribute Details

#sqlObject

Returns the value of attribute sql.



5
6
7
# File 'lib/phoenix/relation.rb', line 5

def sql
  @sql
end

Instance Method Details

#limit(size) ⇒ Object



11
12
13
14
15
16
# File 'lib/phoenix/relation.rb', line 11

def limit(size)
  if size.to_i > 0
    self.sql << " LIMIT #{size}"
  end
  self
end

#order(o) ⇒ Object



18
19
20
21
# File 'lib/phoenix/relation.rb', line 18

def order(o)
  self.sql << " ORDER BY #{o}"
  self
end

#takeObject



23
24
25
# File 'lib/phoenix/relation.rb', line 23

def take
  Phoenix::Rjb.execute(@sql)
end

#to_sqlObject



32
33
34
# File 'lib/phoenix/relation.rb', line 32

def to_sql
  self.sql
end

#where(str) ⇒ Object



27
28
29
30
# File 'lib/phoenix/relation.rb', line 27

def where(str)
  self.sql << str if str.present?
  self
end