Class: OrderedHash

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

Overview

:nodoc:

Direct Known Subclasses

OrderedOptions

Instance Method Summary collapse

Methods inherited from Array

#in_groups_of

Methods included from ActiveSupport::CoreExtensions::Array::Conversions

#to_param, #to_sentence, #to_xml

Instance Method Details

#[](key) ⇒ Object



11
12
13
14
# File 'lib/active_support/ordered_options.rb', line 11

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

#[]=(key, value) ⇒ Object



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

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

#keysObject



16
17
18
# File 'lib/active_support/ordered_options.rb', line 16

def keys
  self.collect { |i| i.first }
end