Class AutomateIt::FieldManager::Struct
In: lib/automateit/field_manager.rb
Parent: AutomateIt::FieldManager::BaseDriver

FieldManager::Struct

A FileManager driver that queries a data structure.

Methods

lookup   setup  

Public Instance methods

See FieldManager#lookup

[Source]

# File lib/automateit/field_manager.rb, line 61
  def lookup(search=nil)
    return @struct if search.nil? or search == "*"
    ref = @struct
    for key in search.to_s.split("#")
      ref = ref[key]
    end
    if ref
      return ref
    else
      raise IndexError.new("can't find value for: #{search}")
    end
  end

Options:

  • :struct — Hash to use as the fields data structure.

[Source]

# File lib/automateit/field_manager.rb, line 50
  def setup(opts={})
    super(opts)

    if opts[:struct]
      @struct = opts[:struct]
    else
      @struct ||= {}
    end
  end

[Validate]