Class: ApacheAge::Entities::Entity
- Inherits:
-
Object
- Object
- ApacheAge::Entities::Entity
- Defined in:
- lib/apache_age/entities/entity.rb
Class Method Summary collapse
- .all ⇒ Object
- .ensure_query_builder! ⇒ Object
- .execute ⇒ Object
- .find(id) ⇒ Object
- .find_by(attributes) ⇒ Object
- .first ⇒ Object
- .limit(limit_value) ⇒ Object
- .match(match_string) ⇒ Object
- .order(ordering) ⇒ Object
- .return(*variables) ⇒ Object
- .to_sql ⇒ Object
- .where(*args) ⇒ Object
Class Method Details
.all ⇒ Object
65 66 67 68 |
# File 'lib/apache_age/entities/entity.rb', line 65 def all ensure_query_builder! @query_builder.all end |
.ensure_query_builder! ⇒ Object
5 6 7 |
# File 'lib/apache_age/entities/entity.rb', line 5 def ensure_query_builder! @query_builder ||= ApacheAge::Entities::QueryBuilder.new(self) end |
.execute ⇒ Object
55 56 57 58 |
# File 'lib/apache_age/entities/entity.rb', line 55 def execute ensure_query_builder! @query_builder.execute end |
.find(id) ⇒ Object
23 |
# File 'lib/apache_age/entities/entity.rb', line 23 def find(id) = find_by(id: id) |
.find_by(attributes) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/apache_age/entities/entity.rb', line 9 def find_by(attributes) where_clause = attributes .map do |k, v| if k == :id ActiveRecord::Base.sanitize_sql(["id(find) = ?", v]) else ActiveRecord::Base.sanitize_sql(["find.#{k} = ?", v]) end end .join(' AND ') handle_find(where_clause) end |
.first ⇒ Object
60 61 62 63 |
# File 'lib/apache_age/entities/entity.rb', line 60 def first ensure_query_builder! @query_builder.first end |
.limit(limit_value) ⇒ Object
43 44 45 46 47 |
# File 'lib/apache_age/entities/entity.rb', line 43 def limit(limit_value) ensure_query_builder! @query_builder.limit(limit_value) self end |
.match(match_string) ⇒ Object
25 26 27 28 29 |
# File 'lib/apache_age/entities/entity.rb', line 25 def match(match_string) ensure_query_builder! @query_builder.match(match_string) self end |
.order(ordering) ⇒ Object
37 38 39 40 41 |
# File 'lib/apache_age/entities/entity.rb', line 37 def order(ordering) ensure_query_builder! @query_builder.order(ordering) self end |
.return(*variables) ⇒ Object
49 50 51 52 53 |
# File 'lib/apache_age/entities/entity.rb', line 49 def return(*variables) ensure_query_builder! @query_builder.return(*variables) self end |
.to_sql ⇒ Object
70 71 72 73 |
# File 'lib/apache_age/entities/entity.rb', line 70 def to_sql ensure_query_builder! @query_builder.to_sql end |
.where(*args) ⇒ Object
31 32 33 34 35 |
# File 'lib/apache_age/entities/entity.rb', line 31 def where(*args) ensure_query_builder! @query_builder.where(*args) self end |