Sha256: 11e740faeea4f1fe1635a3b8b666aa97d0683980b5bc996235b45cc98a1659c0
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
module Fathom class Edge # ============= # Class Methods # ============= class << self def infer(obj, optional_child=nil) return new(:parent => Variable.infer(obj), :child => Variable.infer(optional_child)) if optional_child case obj when Edge obj when Array new(:parent => Variable.infer(obj[0]), :child => Variable.infer(obj[1])) when Hash new(obj) end end end # ============ # = Behavior = # ============ extend Plugins plugin AttributeSystem # ============== # = Attributes = # ============== attribute :is_directed, true attribute :parent attribute :child def initialize(attributes={}) attributes[:parent] = Variable.infer(attributes[:parent]) attributes[:child] = Variable.infer(attributes[:child]) @attributes = attributes end # ============================================================ # = Override setters on parent and child to ensure Variables = # ============================================================ def parent=(obj) send(self.class.attributes_proxy)[:parent] = Variable.infer(obj) end def child=(obj) send(self.class.attributes_proxy)[:child] = Variable.infer(obj) end def eql(other) return false unless other.is_a?(Edge) self.parent == other.parent and self.child == other.child end alias :== :eql end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fathom-0.5.0 | lib/fathom/data/edge.rb |