class Mexico::FileSystem::Item
The basic data unit object.
Attributes
document[RW]
implicit_item_links[RW]
Public Class Methods
new(args={})
click to toggle source
# File lib/mexico/file_system/item.rb, line 65 def initialize(args={}) args.each do |k,v| if self.respond_to?("#{k}=") send("#{k}=", v) end end @explicit_item_links = [] @implicit_item_links = [] @inverse_linked_items = [] @layer_links = [] @point_links = [] @interval_links = [] end
Public Instance Methods
add_explicit_item_link(new_item_link)
click to toggle source
# File lib/mexico/file_system/item.rb, line 130 def add_explicit_item_link(new_item_link) @explicit_item_links << new_item_link end
add_implicit_item_link(new_item_link)
click to toggle source
# File lib/mexico/file_system/item.rb, line 134 def add_implicit_item_link(new_item_link) @implicit_item_links << new_item_link end
add_interval_link(new_interval_link)
click to toggle source
# File lib/mexico/file_system/item.rb, line 143 def add_interval_link(new_interval_link) @interval_links << new_interval_link end
add_inverse_linked_item(item)
click to toggle source
# File lib/mexico/file_system/item.rb, line 104 def add_inverse_linked_item(item) @inverse_linked_items << item end
add_item_link(new_item_link)
click to toggle source
# File lib/mexico/file_system/item.rb, line 108 def add_item_link(new_item_link) # add the item link add_explicit_item_link(new_item_link) other_item = new_item_link.target_item # add an inverse item link for _every_ item link # this is for retrieving item links from the other direction other_item.add_inverse_linked_item(self) # if an inverse relation for the role exists, # puts Mexico::FileSystem::ItemLink::INVERSE_ROLES.has_key?(new_item_link.role) if Mexico::FileSystem::ItemLink::INVERSE_ROLES.has_key?(new_item_link.role) # add an implicit link for this inverse relation # puts new_item_link.target_item other_item.add_implicit_item_link Mexico::FileSystem::ImplicitItemLink.new( role: Mexico::FileSystem::ItemLink::INVERSE_ROLES[new_item_link.role], target_object: self, item: other_item ) end end
add_layer_link(new_layer_link)
click to toggle source
# File lib/mexico/file_system/item.rb, line 148 def add_layer_link(new_layer_link) @layer_links << new_layer_link end
add_point_link(new_point_link)
click to toggle source
# File lib/mexico/file_system/item.rb, line 138 def add_point_link(new_point_link) @point_links << new_point_link end
after_parse()
click to toggle source
This method attempts to link objects from other locations of the XML/object tree into position inside this object, by following the xml ids given in the appropriate fields of this class.
# File lib/mexico/file_system/item.rb, line 82 def after_parse # store self ::Mexico::FileSystem::FiestaDocument.store(self.identifier, self) [item_links,layer_links,point_links,interval_links].flatten.each do |link| link.item = self if ::Mexico::FileSystem::FiestaDocument.knows?(link.target) link.target_object=::Mexico::FileSystem::FiestaDocument.resolve(link.target) else # store i in watch list ::Mexico::FileSystem::FiestaDocument.watch(link.target, link, :target_object=) end end end
identifier=(new_id)
click to toggle source
# File lib/mexico/file_system/item.rb, line 27 def identifier=(new_id) @identifier = Mexico::Util::to_xml_id(new_id) end
item_links()
click to toggle source
# File lib/mexico/file_system/item.rb, line 100 def item_links @explicit_item_links + @implicit_item_links end
layers()
click to toggle source
# File lib/mexico/file_system/item.rb, line 152 def layers #puts layer_links.collect{|l| l.target}.join #puts layer_links.collect{|l| l.target.class }.join layer_links.collect{|l| l.layer } end
sources()
click to toggle source
Retrieves all items that act as a source (or predecessor) in the item link graph.
# File lib/mexico/file_system/item.rb, line 160 def sources @inverse_linked_items end
targets()
click to toggle source
Retrieves all items that act as a target (or successor) in the item link graph.
# File lib/mexico/file_system/item.rb, line 166 def targets item_links.collect{|l| l.target_object } end