Module: HasLocalizationTable::ActiveRecord::OrderedBy

Defined in:
lib/has_localization_table/active_record/ordered_by.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/has_localization_table/active_record/ordered_by.rb', line 4

def method_missing(name, *args, &block)
  if name.to_s =~ /\Aordered_by_([a-z0-9_]+)\Z/
    attribute = $1.to_sym
    return ordered_by_localized_attribute(attribute, *args) if localized_attributes.include?(attribute)
  end
  
  super
end

Instance Method Details

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
# File 'lib/has_localization_table/active_record/ordered_by.rb', line 13

def respond_to?(*args)
  if args.first.to_s =~ /\Aordered_by_([a-z0-9_]+)\Z/
    return true if localized_attributes.include?($1.to_sym)
  end
  
  super
end