-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented 'tag_cloud' support in sqliss.
- Loading branch information
Showing
7 changed files
with
147 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require 'querybuilder' | ||
|
||
module Zena | ||
module Use | ||
class QueryLink | ||
|
||
module ModelMethods | ||
def self.included(base) | ||
base.send(:include, ::QueryBuilder) | ||
base.extend ClassMethods | ||
base.query_compiler = Zena::Use::QueryLink::Compiler | ||
end | ||
end | ||
|
||
module ClassMethods | ||
# Find a node and propagate visitor | ||
def do_find(count, query) | ||
case count | ||
when :all | ||
res = find_by_sql(query) | ||
res.empty? ? nil : res | ||
when :first | ||
find_by_sql(query).first | ||
when :count | ||
count_by_sql(query) | ||
else | ||
nil | ||
end | ||
end | ||
end | ||
|
||
|
||
class Compiler < ::QueryBuilder::Processor | ||
attr_reader :node_name | ||
set_main_table 'links' | ||
set_main_class 'Link' | ||
set_default :order, 'comment ASC' | ||
|
||
# Overwrite this and take car to check for valid fields. | ||
def process_field(field_name) | ||
if %w{comment status date name}.include?(field_name) | ||
field_name = 'comment' if field_name == 'name' | ||
"#{table}.#{field_name}" | ||
else | ||
super # raise an error | ||
end | ||
end | ||
|
||
def map_attr(fld) | ||
# error | ||
nil | ||
end | ||
end # Compiler | ||
|
||
end # QueryLink | ||
end # Use | ||
end # Zena |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters