Class: ActiveTriples::List::ListResource

Inherits:
Object
  • Object
show all
Includes:
RDFSource
Defined in:
lib/active_triples/list.rb

Overview

This class is the graph/Resource that backs the List and supplies integration with the rest of ActiveTriples

Instance Attribute Summary collapse

Attributes included from RDFSource

#parent

Instance Method Summary collapse

Methods included from RDFSource

#[], #[]=, #attributes, #base_uri, #destroy, #destroy_child, #destroyed?, #dump, #fetch, #fields, #final_parent, #get_relation, #get_values, #id, #initialize, #mark_for_destruction, #marked_for_destruction?, #new_record?, #node?, #persist!, #persisted?, #rdf_label, #rdf_subject, #reload, #serializable_hash, #set_subject!, #set_value, #type, #type=, type_registry, #writable?

Methods included from Reflection

add_reflection

Instance Attribute Details

#listObject

Returns the value of attribute list.



103
104
105
# File 'lib/active_triples/list.rb', line 103

def list
  @list
end

Instance Method Details

#attributes=(values) ⇒ Object

Raises:

  • (ArgumentError)


113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/active_triples/list.rb', line 113

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
  persist!
  super
end

#reflectionsObject



109
110
111
# File 'lib/active_triples/list.rb', line 109

def reflections
  @list.class
end