class Refinery::Pages::Finder
Attributes
conditions[RW]
Public Class Methods
by_path(path)
click to toggle source
# File lib/refinery/pages/finder.rb, line 4 def self.by_path(path) FinderByPath.new(path).find end
by_path_or_id(path, id)
click to toggle source
# File lib/refinery/pages/finder.rb, line 8 def self.by_path_or_id(path, id) FinderByPathOrId.new(path, id).find end
by_slug(slug, conditions = {})
click to toggle source
# File lib/refinery/pages/finder.rb, line 16 def self.by_slug(slug, conditions = {}) FinderBySlug.new(slug, conditions).find end
by_title(title)
click to toggle source
# File lib/refinery/pages/finder.rb, line 12 def self.by_title(title) FinderByTitle.new(title).find end
new(conditions)
click to toggle source
# File lib/refinery/pages/finder.rb, line 24 def initialize(conditions) @conditions = conditions end
with_globalize(conditions = {})
click to toggle source
# File lib/refinery/pages/finder.rb, line 20 def self.with_globalize(conditions = {}) Finder.new(conditions).find end
Public Instance Methods
find()
click to toggle source
# File lib/refinery/pages/finder.rb, line 28 def find with_globalize end
with_globalize()
click to toggle source
# File lib/refinery/pages/finder.rb, line 32 def with_globalize globalized_conditions = {:locale => ::Globalize.locale.to_s}.merge(conditions) translations_conditions = translations_conditions(globalized_conditions) # A join implies readonly which we don't really want. Page.where(globalized_conditions). joins(:translations). where(translations_conditions). readonly(false) end
Private Instance Methods
translated_attributes()
click to toggle source
# File lib/refinery/pages/finder.rb, line 46 def translated_attributes Page.translated_attribute_names.map(&:to_s) | %w(locale) end
translations_conditions(original_conditions)
click to toggle source
# File lib/refinery/pages/finder.rb, line 50 def translations_conditions(original_conditions) translations_conditions = {} original_conditions.keys.each do |key| if translated_attributes.include? key.to_s translations_conditions["#{Page.translation_class.table_name}.#{key}"] = original_conditions.delete(key) end end translations_conditions end