class ActiveTriples::List::ListResource
This class is the graph/Resource that backs the List
and supplies integration with the rest of ActiveTriples
Attributes
list[R]
Public Instance Methods
attributes=(values)
click to toggle source
Calls superclass method
ActiveTriples::RDFSource#attributes=
# File lib/active_triples/list.rb, line 105 def attributes=(values) raise ArgumentError, "values must be a Hash, you provided #{values.class}" unless values.kind_of? Hash values.with_indifferent_access.each do |key, value| if reflections.properties.keys.map { |k| "#{k}_attributes" }.include?(key) klass = reflections.reflect_on_property(key[0..-12])['class_name'] klass = ActiveTriples.class_from_string(klass, final_parent.class) if klass.is_a? String value.is_a?(Hash) ? attributes_hash_to_list(values[key], klass) : attributes_to_list(value, klass) values.delete key end end super end
list=(list)
click to toggle source
# File lib/active_triples/list.rb, line 97 def list=(list) @list ||= list end
reflections()
click to toggle source
# File lib/active_triples/list.rb, line 101 def reflections @list.class end
Protected Instance Methods
erase_old_resource()
click to toggle source
Clear out any old assertions in the repository about this node or statement thus preparing to receive the updated assertions.
# File lib/active_triples/list.rb, line 122 def erase_old_resource RDF::List.new(subject: rdf_subject, graph: self).clear end
Private Instance Methods
attributes_hash_to_list(value, klass)
click to toggle source
# File lib/active_triples/list.rb, line 136 def attributes_hash_to_list(value, klass) value.each do |counter, attr| item = klass.new() item.attributes = attr if attr list[counter.to_i] = item end end
attributes_to_list(value, klass)
click to toggle source
# File lib/active_triples/list.rb, line 128 def attributes_to_list(value, klass) value.each do |entry| item = klass.new() item.attributes = entry list << item end end