Sha256: bb8e4b9ea1c684ceaed76b5d3c7e0f04a2f294aabcb5b2b73bc31d71b837d3c8

Contents?: true

Size: 560 Bytes

Versions: 1

Compression:

Stored size: 560 Bytes

Contents

require 'whitelist_scope'

module Sortify
  include WhitelistScope
  alias_method :sort_option, :whitelist_scope
  alias_method :sort_options, :whitelist

  def default_sort_option(name)
    @default_sort_option = name.to_sym
  end

  def sortify(sort_option = '')
    if sort_option.empty?
      begin
        call_whitelisted_scope(@default_sort_option)
      rescue
        raise NoMethodError, "The default sort option you provided, '#{@default_sort_option}', does not exist."
      end
    else
      call_whitelisted_scope(sort_option)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sortify-0.1.7 lib/sortify.rb