Class: AnyLogin::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/any_login/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection_raw) ⇒ Collection

Returns a new instance of Collection.



5
6
7
# File 'lib/any_login/collection.rb', line 5

def initialize(collection_raw)
  @collection_raw = collection_raw
end

Instance Attribute Details

#collection_rawObject (readonly)

Returns the value of attribute collection_raw.



3
4
5
# File 'lib/any_login/collection.rb', line 3

def collection_raw
  @collection_raw
end

Instance Method Details

#grouped?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/any_login/collection.rb', line 9

def grouped?
  type == :grouped
end

#to_aObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# 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