Sha256: db7286896bfd926dfce869ff91fa035792cfad2943809cf3860c7a747c74d811

Contents?: true

Size: 860 Bytes

Versions: 3

Compression:

Stored size: 860 Bytes

Contents

#
# predefined methods: update_state, apply, reset, resolve
#
module Sfp::Resource
	@@resource = Object.new.extend(Sfp::Resource)

	def self.resolve(path)
		@@resource.resolve(path)
	end

	attr_accessor :parent, :synchronized
	attr_reader :state, :model

	def init(model={})
		@model = {}
		@state = {}
		@synchronized = []

		update_model(model)
	end

	def update_state
		@state = {}
	end

	def update_model(model)
		model.each { |k,v| @model[k] = v }
	end

	def apply(p={})
		true
	end

	def to_model
		@state = {}
		@model.each { |k,v| @state[k] = v }
	end

	alias_method :reset, :to_model

	def resolve(path)
		Sfp::Agent.resolve(path.simplify)
	end

	protected
	def exec_seq(*commands)
		commands = [commands.to_s] if not commands.is_a?(Array)
		commands.each { |c| raise Exception, "Cannot execute: #{c}" if !system(c) }
	end
end

module Sfp::Module
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sfpagent-0.2.4 lib/sfpagent/module.rb
sfpagent-0.2.3 lib/sfpagent/module.rb
sfpagent-0.1.14 lib/sfpagent/module.rb