Commit 6ee60cca authored by Brice Sanchez's avatar Brice Sanchez Committed by Philip Arndt
Browse files

now use `Module#prepend` instead of `class_eval` (#17)


Co-authored-by: default avatarPhilip Arndt <git@p.arndt.io>
parent 09190c03
require 'acts_as_indexed'
begin
Refinery::Blog::Category.class_eval do
acts_as_indexed :fields => [:title] unless self.respond_to? :with_query
module RefineryBlogCategoryAddActsAsIndexed
def self.prepended(base)
base.acts_as_indexed fields: [:title] unless self.respond_to? :with_query
end
rescue NameError
end
Refinery::Blog::Category.prepend(RefineryBlogCategoryAddActsAsIndexed) rescue NameError
require 'acts_as_indexed'
begin
Refinery::Blog::Comment.class_eval do
acts_as_indexed :fields => [:name, :email, :message] unless self.respond_to? :with_query
module RefineryBlogCommentAddActsAsIndexed
def self.prepended(base)
base.acts_as_indexed fields: [:name, :email, :message] unless self.respond_to? :with_query
end
rescue NameError
end
Refinery::Blog::Comment.prepend(RefineryBlogCommentAddActsAsIndexed) rescue NameError
require 'acts_as_indexed'
begin
Refinery::Blog::Post.class_eval do
acts_as_indexed :fields => [:title, :custom_teaser, :body] unless self.respond_to? :with_query
module RefineryBlogPostAddActsAsIndexed
def self.prepended(base)
base.acts_as_indexed fields: [:title, :custom_teaser, :body] unless self.respond_to? :with_query
end
rescue NameError
end
Refinery::Blog::Post.prepend(RefineryBlogPostAddActsAsIndexed) rescue NameError
require 'acts_as_indexed'
begin
Refinery::Image.class_eval do
# Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
acts_as_indexed :fields => [:title] unless self.respond_to? :with_query
module RefineryImageAddActsAsIndexed
def self.prepended(base)
base.acts_as_indexed fields: [:title] unless self.respond_to? :with_query
end
rescue NameError
end
Refinery::Image.prepend(RefineryImageAddActsAsIndexed) rescue NameError
require 'acts_as_indexed'
begin
Refinery::Inquiries::Inquiry.class_eval do
acts_as_indexed :fields => [:name, :email, :message, :phone] unless self.respond_to? :with_query
module RefineryInquiriesInquiryAddActsAsIndexed
def self.prepended(base)
base.acts_as_indexed fields: [:name, :email, :message, :phone] unless self.respond_to? :with_query
end
rescue NameError
end
Refinery::Inquiries::Inquiry.prepend(RefineryInquiriesInquiryAddActsAsIndexed) rescue NameError
require 'acts_as_indexed'
require 'stringex_lite'
begin
Refinery::Page.class_eval do
# Docs for acts_as_indexed https://github.com/dougal/acts_as_indexed
module RefineryPageAddActsAsIndexed
def self.prepended(base)
unless self.respond_to? :with_query
acts_as_indexed :fields => [:ascii_title, :meta_description,
:menu_title, :browser_title,
:ascii_all_page_part_content]
end
# Used to index all the content on this page so it can be easily searched.
def all_page_part_content
parts.map(&:body).join " "
base.acts_as_indexed(fields: [
:ascii_title, :meta_description,
:menu_title, :browser_title, :ascii_all_page_part_content
])
end
end
# Used to index all the content on this page so it can be easily searched.
def all_page_part_content
parts.map(&:body).join " "
end
private
private
def ascii_title
self.title.try(&:to_ascii)
end
def ascii_title
self.title.try(&:to_ascii)
end
def ascii_all_page_part_content
self.all_page_part_content.try(&:to_ascii)
end
def ascii_all_page_part_content
self.all_page_part_content.try(&:to_ascii)
end
rescue NameError
end
Refinery::Page.prepend(RefineryPageAddActsAsIndexed) rescue NameError
require 'acts_as_indexed'
begin
Refinery::Resource.class_eval do
# Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
acts_as_indexed :fields => [:file_name, :title, :type_of_content] unless self.respond_to? :with_query
module RefineryResourceAddActsAsIndexed
def self.prepended(base)
base.acts_as_indexed fields: [:file_name, :title, :type_of_content] unless self.respond_to? :with_query
end
rescue NameError
end
Refinery::Resource.prepend(RefineryResourceAddActsAsIndexed) rescue NameError
require 'acts_as_indexed'
begin
Refinery::Setting.class_eval do
# Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
acts_as_indexed :fields => [:name] unless self.respond_to? :with_query
module RefinerySettingAddActsAsIndexed
def self.prepended(base)
base.acts_as_indexed fields: [:name] unless self.respond_to? :with_query
end
rescue NameError
end
Refinery::Setting.prepend(RefinerySettingAddActsAsIndexed) rescue NameError
require 'acts_as_indexed'
begin
Refinery::Authentication::Devise::User.class_eval do
# Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
acts_as_indexed :fields => [:username, :email] unless self.respond_to? :with_query
module RefineryAuthenticationDeviseUserAddActsAsIndexed
def self.prepended(base)
base.acts_as_indexed fields: [:username, :email] unless self.respond_to? :with_query
end
rescue NameError
end
Refinery::Authentication::Devise::User.prepend(RefineryAuthenticationDeviseUserAddActsAsIndexed) rescue NameError
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment