Module: Noah::Linkable

Included in:
Application, Configuration, Ephemeral, Host, Service, Token
Defined in:
lib/noah/linkable.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(model) ⇒ Object


2
3
4
5
# File 'lib/noah/linkable.rb', line 2

def self.included(model)
  model.send :set, :links, ::Noah::Link
  model.send :index, :links
end

Instance Method Details

#link!(link_name) ⇒ Object


7
8
9
10
11
# File 'lib/noah/linkable.rb', line 7

def link!(link_name)
  link = Noah::Link.find_or_create(:path => link_name)
  link.nodes = self
  links << link
end

#to_hashObject


16
17
18
19
20
# File 'lib/noah/linkable.rb', line 16

def to_hash
  link_arr = Array.new
  self.links.sort.each {|l| link_arr << l.path} if self.links.size != 0
  super.merge(:links => link_arr)
end

#unlink!(link_name) ⇒ Object


13
14
# File 'lib/noah/linkable.rb', line 13

def unlink!(link_name)
end