Skip to content

Instantly share code, notes, and snippets.

@raphink
Created June 27, 2013 14:25
Show Gist options
  • Save raphink/5876847 to your computer and use it in GitHub Desktop.
Save raphink/5876847 to your computer and use it in GitHub Desktop.
positionable do
def insync?(is)
# define sync
end
end
ensurable do
desc "Ensure the presence, absence or position of the entry"
defaultvalues
newvalue(:positioned) do
current = self.retrieve
if current == :absent
provider.create
elsif !provider.in_position?
provider.destroy
provider.create
end
end
def insync?(is)
return true if should == :positioned and is == :present and provider.in_position?
super
end
end
# Implies the code above (including ensurable)
positionable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment