Class: Bowline::OrderedOptions

Inherits:
Array show all
Defined in:
lib/bowline/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

Methods inherited from Array

#to_js

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



635
636
637
638
639
640
641
# File 'lib/bowline/initializer.rb', line 635

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



630
631
632
633
# File 'lib/bowline/initializer.rb', line 630

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

#[]=(key, value) ⇒ Object

:nodoc:



619
620
621
622
623
624
625
626
627
628
# File 'lib/bowline/initializer.rb', line 619

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

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