Module: Noah::ModelClassMethods
- Defined in:
- lib/noah/models.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
29 30 31 |
# File 'lib/noah/models.rb', line 29 def self.included(base) Noah::RegisteredModels.register_model(base) end |
Instance Method Details
#is_new? ⇒ Boolean
33 34 35 |
# File 'lib/noah/models.rb', line 33 def is_new? self.created_at == self.updated_at end |
#link!(path) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/noah/models.rb', line 37 def link!(path) base_pattern = "#{self.patternize_me}" path.nil? ? (raise ArgumentError, "Must provide a path") : p=path begin l = Link.find_or_create :path => p l.nodes = self rescue Exception => e e. end end |
#watch!(opts = {:endpoint => nil}) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/noah/models.rb', line 49 def watch!(opts={:endpoint => nil}) base_pattern = "#{self.patternize_me}" opts[:endpoint].nil? ? (raise ArgumentError, "Need an endpoint") : endpoint=opts[:endpoint] begin w = Watcher.new :pattern => base_pattern, :endpoint => endpoint w.valid? ? w.save : (raise "#{w.errors}") w.name rescue Exception => e e. end end |