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
-
#property_flush ⇒ Object
readonly
Returns the value of attribute property_flush.
-
#property_hash ⇒ Object
readonly
Returns the value of attribute property_hash.
Class Method Summary collapse
Instance Method Summary collapse
-
#create ⇒ Object
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.
-
#destroy ⇒ Object
Destroy the resource based on: - the command set on the Type - The on_destroy value of the Type.
-
#exists? ⇒ Boolean
Checks if the resource exists.
-
#flush ⇒ Object
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.
- #initialize(value = {}) ⇒ Object
Instance Attribute Details
#property_flush ⇒ Object (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 |
#property_hash ⇒ Object (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
.included(parent) ⇒ Object
29 30 31 |
# File 'lib/easy_type/provider.rb', line 29 def self.included(parent) parent.extend(ClassMethods) end |
Instance Method Details
#create ⇒ Object
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(:on_create) command.execute @property_flush = {} end |
#destroy ⇒ Object
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 = build_from_type(:on_destroy) command.execute @property_hash.clear @property_flush = {} end |
#exists? ⇒ Boolean
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? not @property_hash[:ensure].nil? end |
#flush ⇒ Object
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(:on_modify) command.execute end end |
#initialize(value = {}) ⇒ Object
34 35 36 37 |
# File 'lib/easy_type/provider.rb', line 34 def initialize(value = {}) super(value) @property_flush = {} end |