Module: EasyType::Provider
- Defined in:
- lib/easy_type/provider.rb
Overview
EasyType is a flushable provider. To use this provider, you have to add certain information to the type definition. You MUST define following attributes on the type
on_create do
"create user #{self[:name]}"
end
on_modify do
"alter user #{self[:name]}"
end
on_destroy do
"drop user #{self[:name]}"
end
for all properties you MUST add
on_apply do
"identified by #{resource[:password]}"
end
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary (collapse)
-
- (Object) property_flush
readonly
Returns the value of attribute property_flush.
-
- (Object) property_hash
readonly
Returns the value of attribute property_hash.
Class Method Summary (collapse)
Instance Method Summary (collapse)
-
- (Object) create
Create the resource based on: - The values in the property_hash - the command set on the Type - The on_create value of the Type - The on_apply values of all the specified parameters and properties.
-
- (Object) destroy
Destroy the resource based on: - the command set on the Type - The on_destroy value of the Type.
-
- (Boolean) exists?
Checks if the resource exists.
-
- (Object) flush
Modify the resource based on: - The values in the property_hash - the command set on the Type - The on_modify value of the Type - The on_apply values of all the specified parameters and properties.
- - (Object) initialize(value = {})
Instance Attribute Details
- (Object) property_flush (readonly)
Returns the value of attribute property_flush
26 27 28 |
# File 'lib/easy_type/provider.rb', line 26 def property_flush @property_flush end |
- (Object) property_hash (readonly)
Returns the value of attribute property_hash
26 27 28 |
# File 'lib/easy_type/provider.rb', line 26 def property_hash @property_hash end |
Class Method Details
+ (Object) included(parent)
29 30 31 |
# File 'lib/easy_type/provider.rb', line 29 def self.included(parent) parent.extend(ClassMethods) end |
Instance Method Details
- (Object) create
Create the resource based on:
- The values in the property_hash
- the command set on the Type
- The on_create value of the Type
- The on_apply values of all the specified parameters and properties
56 57 58 59 60 61 62 |
# File 'lib/easy_type/provider.rb', line 56 def create @property_flush = @resource @property_hash[:ensure] = :present command = build_from_type(resource.on_create) command.execute @property_flush = {} end |
- (Object) destroy
Destroy the resource based on:
- the command set on the Type
- The on_destroy value of the Type
69 70 71 72 73 74 |
# File 'lib/easy_type/provider.rb', line 69 def destroy command = CommandBuilder.new(model, resource.method(:command), resource.on_destroy) command.execute @property_hash.clear @property_flush = {} end |
- (Boolean) exists?
Checks if the resource exists. It does that by checking if the ensure property in the property_hash contains :present
45 46 47 |
# File 'lib/easy_type/provider.rb', line 45 def exists? @property_hash[:ensure] == :present end |
- (Object) flush
Modify the resource based on:
- The values in the property_hash
- the command set on the Type
- The on_modify value of the Type
- The on_apply values of all the specified parameters and properties
83 84 85 86 87 88 |
# File 'lib/easy_type/provider.rb', line 83 def flush if @property_flush && @property_flush != {} command = build_from_type(resource.on_modify) command.execute end end |
- (Object) initialize(value = {})
34 35 36 37 |
# File 'lib/easy_type/provider.rb', line 34 def initialize(value={}) super(value) @property_flush = {} end |