Class: AutomateIt::FieldManager::Struct

Inherits:
BaseDriver show all
Defined in:
lib/automateit/field_manager.rb

Overview

FieldManager::Struct

A FileManager driver that queries a data structure.

Direct Known Subclasses

YAML

Constant Summary

Constants inherited from Plugin::Driver

Plugin::Driver::BASE_DRIVER_NAME

Constants included from Constants

Constants::HELPERS_DIR, Constants::INSTALL_DIR, Constants::PERROR, Constants::PEXEC, Constants::PNOTE, Constants::WARNING_BOILERPLATE

Instance Attribute Summary

Attributes inherited from Plugin::Driver

#manager

Attributes inherited from Common

#interpreter

Instance Method Summary collapse

Methods inherited from Plugin::Driver

abstract_driver, #available?, base_driver, base_driver?, depends_on, inherited, manager_token

Methods inherited from Plugin::Base

#token, token

Methods inherited from Common

#initialize, #log, #nitpick, #noop, #noop=, #noop?, #preview, #preview=, #preview?, #preview_for, #superuser?, #writing, #writing=, #writing?

Constructor Details

This class inherits a constructor from AutomateIt::Common

Instance Method Details

#lookup(search = nil) ⇒ Object

See FieldManager#lookup



61
62
63
64
65
66
67
68
69
70
71
72
# 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

#setup(opts = {}) ⇒ Object

Options:

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



50
51
52
53
54
55
56
57
58
# File 'lib/automateit/field_manager.rb', line 50

def setup(opts={})
  super(opts)

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

#suitability(method, *args) ⇒ Object

:nodoc:



44
45
46
# File 'lib/automateit/field_manager.rb', line 44

def suitability(method, *args) # :nodoc:
  return 1
end