Class: OrderedOptions
- Inherits:
-
Array
show all
- Defined in:
- lib/active_support/ordered_options.rb
Overview
Instance Method Summary
collapse
#to_param, #to_sentence
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/active_support/ordered_options.rb', line 18
def method_missing(name, *args)
if name.to_s =~ /(.*)=$/
self[$1.to_sym] = args.first
else
self[name]
end
end
|
Instance Method Details
13
14
15
16
|
# File 'lib/active_support/ordered_options.rb', line 13
def [](key)
pair = find_pair(key.to_sym)
pair ? pair.last : nil
end
|
#[]=(key, value) ⇒ Object
2
3
4
5
6
7
8
9
10
11
|
# File 'lib/active_support/ordered_options.rb', line 2
def []=(key, value)
key = key.to_sym
if pair = find_pair(key)
pair.pop
pair << value
else
self << [key, value]
end
end
|