class Adobe::Aem::Jcr::Node
Public Class Methods
new(hash = {}, path, context)
click to toggle source
# File lib/adobe/aem/jcr/node.rb, line 5 def initialize(hash = {}, path, context) @context = context @path = path @data = hash end
Public Instance Methods
child_exists?(name)
click to toggle source
# File lib/adobe/aem/jcr/node.rb, line 25 def child_exists?(name) @data.has_key?(name) end
children()
click to toggle source
# File lib/adobe/aem/jcr/node.rb, line 11 def children @data.select do |key, value| value.is_a? Hash end end
create_child(title, options = {})
click to toggle source
# File lib/adobe/aem/jcr/node.rb, line 29 def create_child(title, options = {}) options = { title: title, label: title, template: '' }.merge(options) @connector.create_page(@path, options[:title], options[:label], options[:template]) end
jcr_content()
click to toggle source
# File lib/adobe/aem/jcr/node.rb, line 17 def jcr_content self.send('jcr:content') end
jcr_content=(value)
click to toggle source
# File lib/adobe/aem/jcr/node.rb, line 21 def jcr_content=(value) self.send('jcr:content=', value) end
length()
click to toggle source
# File lib/adobe/aem/jcr/node.rb, line 71 def length children.length end
Also aliased as: size
method_missing(name, *args, &block)
click to toggle source
# File lib/adobe/aem/jcr/node.rb, line 39 def method_missing(name, *args, &block) # If we're trying to set content of a node that doesn't exist # we should throw exception # # /bin/wcmcommand # cmd:createPage # parentPath:/etc/replication/agents.author # title:Test # label:Test # template:/libs/cq/replication/templates/agent setter = name =~ /=$/ if name.to_s =~ /^\[\]/ name = args.delete_at(0) end if setter return set(name, *args) end unless @data[name.to_s].is_a?(Hash) return @data[name.to_s] end if name.to_s =~ /=$/ else @context.connector.get("#{@path}/#{name}.1.json") end end
Private Instance Methods
set(name, value)
click to toggle source
# File lib/adobe/aem/jcr/node.rb, line 77 def set(name, value) field_name = name.to_s.gsub(/=$/, '') @context.connector.set(@path, field_name, value) end