class Locomotive::Steam::Adapters::Memory::Order
Attributes
list[R]
Public Class Methods
new(*spec)
click to toggle source
# File lib/locomotive/steam/adapters/memory/order.rb, line 9 def initialize(*spec) @list = [] spec.compact.each do |criterion| @list += (case criterion when Array then criterion when Hash then criterion.to_a when String then criterion.split(',').collect { |s| build(s.strip) } else [] end) end end
Public Instance Methods
apply_to(entry, locale)
click to toggle source
# File lib/locomotive/steam/adapters/memory/order.rb, line 25 def apply_to(entry, locale) @list.collect do |(name, direction)| value = entry.send(name) if value.respond_to?(:translations) # localized value = value[locale] end asc?(direction) ? Asc.new(value) : Desc.new(value) end end
asc?(direction)
click to toggle source
# File lib/locomotive/steam/adapters/memory/order.rb, line 37 def asc?(direction) direction.nil? || direction.to_sym == :asc end
empty?()
click to toggle source
# File lib/locomotive/steam/adapters/memory/order.rb, line 21 def empty? @list.empty? end
Private Instance Methods
build(string)
click to toggle source
# File lib/locomotive/steam/adapters/memory/order.rb, line 43 def build(string) pattern = string.include?('.') ? '.' : ' ' string.downcase.split(pattern).map(&:to_sym) end