This file contains hidden or 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
# /app/models/concerns/query_object.rb | |
module QueryObject | |
extend ActiveSupport::Concern | |
module ClassMethods | |
# Convenience method to execute a query object. | |
def execute(*args) | |
new(*args).execute | |
end | |
end |
This file contains hidden or 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
# /app/queries/item_search_query.rb | |
class ItemSearchQuery | |
def self.execute(*args) | |
new(*args).execute | |
end | |
def initialize(query_string, opts = {}) | |
@query_string = query_string | |
@opts = opts | |
end |
This file contains hidden or 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
# /app/models/item.rb | |
class Item < ActiveRecord::Base | |
include ItemSearch | |
... | |
end | |
# /app/models/concerns/item_search.rb | |
module ItemSearch | |
extend ActiveSupport::Concern |
This file contains hidden or 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
# /app/models/item.rb | |
class Item < ActiveRecord::Base | |
... | |
def self.search(query_string, opts = {}) | |
# Build the query | |
search_body = Jbuilder.encode do |json| | |
json.query do | |
json.filtered do | |
json.query do |
This file contains hidden or 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
premailer = Premailer.new "<html><body>some text</body></html>", | |
line_length: 10000, # Arbitrary length to prevent newlines from being added every 65 characters. | |
with_html_string: true # Let premailer know that this is a raw HTML string vs. an IO object or local path. | |
premailer.to_plain_text # => "some text" |
This file contains hidden or 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
class EmailProcessor | |
# @return [void] | |
def self.process(*args) | |
new(*args).process | |
end | |
# @param email [Gridler::Email] | |
# | |
# @return [EmailProcessor] |