lib/iron/settings/cursor.rb
# Look for the next item from our current group pointer,
# returning a new cursor if the item is a sub-group, or the value
# of the requested entry if the item is a leaf in the
# hierarchy tree.
Look for the next item from our current group pointer,
returning a new cursor if the item is a sub-group, or the value
of the requested entry if the item is a leaf in the
hierarchy tree.
Look for the next item from our current group pointer returning a new cursor if the item is a sub - group or the value of the requested entry if the item is a leaf in the hierarchy tree .
def method_missing(method, *args, &block)
      method = method.to_s
      query = method.ends_with?('?')
      assignment = method.ends_with?('=')
      method.gsub!(/[=\?]+/,'')
      item = @group.find_item(method)
      if item.nil?
        if query
          return false
        else
          raise RuntimeError.new("Unknown settings group or entry '#{method}' for settings path #{@group.key}")
        end
      elsif item.group?
        if query
          return true
        else
          cursor = Settings::Cursor.new(item, @values)
          DslProxy::exec(cursor, &block) if block
          return cursor
        end
      elsif item.entry?
        if query
          return !item_value(item).nil?
        else
          if args.empty?
            return item_value(item)
          else
            val = Settings.parse(args.first, item.type)
            @values.set_value(item.key, val)
            return args.first
          end
        end
      end
    end
def method_missing ( method , * args , & block ) method = method . to_s query = method . ends_with? ( '?' ) assignment = method . ends_with? ( '=' ) method . gsub! ( / [= \? ]+ / , '' ) item = @group . find_item ( method ) if item . nil? if query return false else raise RuntimeError . new ( "Unknown settings group or entry '#{method}' for settings path #{@group.key}" ) end elsif item . group? if query return true else cursor = Settings :: Cursor . new ( item , @values ) DslProxy :: exec ( cursor , & block ) if block return cursor end elsif item . entry? if query return ! item_value ( item ) . nil? else if args . empty? return item_value ( item ) else val = Settings . parse ( args . first , item . type ) @values . set_value ( item . key , val ) return args . first end end end end
Look for the next item from our current group pointer,
returning a new cursor if the item is a sub-group, or the value
of the requested entry if the item is a leaf in the
hierarchy tree.
Look for the next item from our current group pointer returning a new cursor if the item is a sub - group or the value of the requested entry if the item is a leaf in the hierarchy tree .
# Look up the item # Unknown item name, whoops. # Querying for existence of key is fine if it's missing # Setting or getting, GTFO # Yes, this group exists # Got asked for another group, so create a new cursor and do the right thing(tm) # Return true if the given item has a non-nil value # No args means return the current value (or default if none) # With args, we set the current value of the item (if it parses correctly)
method
<not_specific>
args
<not_specific>
block
<not_specific>