Class: ActiveSupport::OrderedHash

Inherits:
Array show all
Defined in:
lib/active_support/ordered_options.rb

Overview

:nodoc:

Direct Known Subclasses

OrderedOptions

Instance Method Summary collapse

Methods included from CoreExtensions::Array::Grouping

#in_groups_of, #split

Methods included from CoreExtensions::Array::Conversions

included, #to_formatted_s, #to_param, #to_sentence, #to_xml

Instance Method Details

#[](key) ⇒ Object



13
14
15
16
# File 'lib/active_support/ordered_options.rb', line 13

def [](key)
  pair = assoc(key)
  pair ? pair.last : nil
end

#[]=(key, value) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/active_support/ordered_options.rb', line 4

def []=(key, value)
  if pair = assoc(key)
    pair.pop
    pair << value
  else
    self << [key, value]
  end
end

#keysObject



18
19
20
# File 'lib/active_support/ordered_options.rb', line 18

def keys
  collect { |key, value| key }
end

#valuesObject



22
23
24
# File 'lib/active_support/ordered_options.rb', line 22

def values
  collect { |key, value| value }
end