class AnyLogin::Collection

Attributes

collection_raw[R]

Public Class Methods

new(collection_raw) click to toggle source
# File lib/any_login/collection.rb, line 5
def initialize(collection_raw)
  @collection_raw = collection_raw
end

Public Instance Methods

grouped?() click to toggle source
# File lib/any_login/collection.rb, line 9
def grouped?
  type == :grouped
end
to_a() click to toggle source
# File lib/any_login/collection.rb, line 13
def to_a
  collection_raw.collect do |e|
    if grouped?
      [e[0], e[1].collect(&AnyLogin.name_method)]
    else
      if AnyLogin.name_method.is_a?(Symbol)
        e.send(AnyLogin.name_method)
      else
        AnyLogin.name_method.call(e)
      end
    end
  end
end

Private Instance Methods

type() click to toggle source
# File lib/any_login/collection.rb, line 29
def type
  @type ||= if collection_raw[0].is_a?(Array)
              :grouped
            else
              :single
            end
end