Sha256: 5e9caf32a2904b81ab00b8a313b612364af24a7aca2bff0ba1f88efa978a779d
Contents?: true
Size: 859 Bytes
Versions: 10
Compression:
Stored size: 859 Bytes
Contents
# class to handle/manage and keep track of list of links in this doc module PMP class Links < HashWithIndifferentAccess include Utils attr_accessor :parent def initialize(parent) super() self.parent = parent end def []=(k, link) super set_parent(link) add_link_name(k) end def add_link_name(name) name = name.to_sym unless parent.respond_to?(name) parent.define_singleton_method(name) { self.links[name] } parent.define_singleton_method("#{name}=") { |x| self.links[name] = x } end end def set_parent(link) if link.respond_to?(:parent) link.parent = self.parent elsif link.is_a?(Hash) link.values.each{|l| set_parent(l)} elsif link.is_a?(Enumerable) link.each{|l| set_parent(l)} end end end end
Version data entries
10 entries across 10 versions & 1 rubygems