0
property :location, :string, :nullable => false, :length => 255
0
property :created_at, :datetime
0
- before_destroy :deregister
0
- # This registers the snippet within the view hooks
0
- # Register the snippet view
0
- Hooks::View.register_view self.id do
0
- { :name => self.location, :content => self.content }
0
+ # This registers all snippets
0
+ # Loop through all snippets
0
+ Snippet.all.each do |snippet|
0
+ # Register the snippet view
0
+ Hooks::View.register_dynamic_view(snippet.location, snippet.content, snippet.id)
0
+ # Add the snippet to the array of registered snippets
0
+ @@registered[snippet.id] = {:location => snippet.location, :created_at => snippet.created_at}
0
- # Add the snippet to the array of registered snippets
0
- @@registered[self.id] = {:location => self.location, :created_at => self.created_at}
0
- # This deregisters the snippet from the view hooks
0
- # Deregister the snippet view
0
- Hooks::View.deregister_view self.id
0
- # Remove the snippet from the array of registered snippets
0
- @@registered.delete(self.id)
0
- # This returns true if the snippet has been registered, false otherwise
0
- @@registered.include?(self.id)
0
- # This returns true if the snippet has been registered and is up to date, false otherwise
0
- self.registered? && @@registered[self.id][:location] == self.location && @@registered[self.id][:created_at] == self.created_at
0
+ # This removes all snippets currently registered
0
+ def deregister_snippets
0
+ # Loop through all registered snippets
0
+ @@registered.keys.each do |id|
0
+ # Deregister the snippet view
0
+ Hooks::View.deregister_dynamic_view(id)
0
+ # Remove the snippet from the registered array
0
+ @@registered.delete(id)
Comments
No one has commented yet.