Class: Rails::OrderedOptions

Inherits:
Array
  • Object
show all
Defined in:
lib/rails-2.3.14/initializer.rb

Overview

Needs to be duplicated from Active Support since its needed before Active Support is available. Here both Options and Hash are namespaced to prevent conflicts with other implementations AND with the classes residing in Active Support.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



1164
1165
1166
1167
1168
1169
1170
# File 'lib/rails-2.3.14/initializer.rb', line 1164

def method_missing(name, *args)
  if name.to_s =~ /(.*)=$/
    self[$1.to_sym] = args.first
  else
    self[name]
  end
end

Instance Method Details

#[](key) ⇒ Object



1159
1160
1161
1162
# File 'lib/rails-2.3.14/initializer.rb', line 1159

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

#[]=(key, value) ⇒ Object

:nodoc:



1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
# File 'lib/rails-2.3.14/initializer.rb', line 1148

def []=(key, value)
  key = key.to_sym

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