Method: Element#method_missing
- Defined in:
- lib/element/element.rb
#method_missing(m, *args, &_) ⇒ Object
Public: Gets/sets element attribute via accessor. NOT FOR USE IN TESTS.
m - Symbol or String name of attribute. args - Splat Array of Object arguments. When used like a setter, assigns the first item as the value. _ - Block unused.
Returns nothing.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/element/element.rb', line 43 def method_missing(m, *args, &_) m = m.to_s m_key = m.sub(/=$/, '') raise %Q(No attribute "#{m_key}"!) unless @hash.keys.include?(m_key) if m_key.eql?(m) @hash[m_key] else @hash[m_key] = args.first end end |