module ActiveTriples::Properties

Implements property configuration in the style of RDFSource. It does its work at the class level, and is meant to be extended.

Collaborates closely with ActiveTriples::Reflection

@example define properties at the class level

property :title, predicate: RDF::DC.title, class_name: ResourceClass

@example using property setters & getters

resource.property :title, predicate: RDF::DC.title, 
                          class_name: ResourceClass

resource.title = 'Comet in Moominland'

resource.title                # => ['Comet in Moominland']
resource.title(literal: true) # => [RDF::Literal('Comet in Moominland')]

@see {ActiveTriples::Reflection} @see {ActiveTriples::PropertyBuilder}

Private Instance Methods

fields() click to toggle source

Lists fields registered as properties on the object.

@return [Array<Symbol>] the list of registered properties.

# File lib/active_triples/properties.rb, line 48
def fields
  properties.keys.map(&:to_sym).reject{ |x| x == :type }
end
properties() click to toggle source

Returns the properties registered and their configurations.

@return [ActiveSupport::HashWithIndifferentAccess{String => ActiveTriples::NodeConfig}]

# File lib/active_triples/properties.rb, line 40
def properties
  _active_triples_config
end
registered_predicates() click to toggle source

List of RDF predicates registered as properties on the object.

@return [Array<RDF::URI>]

# File lib/active_triples/properties.rb, line 56
def registered_predicates
  properties.values.map { |config| config.predicate }
end
unregistered_predicates() click to toggle source

List of RDF predicates used in the Resource's triples, but not mapped to any property or accessor methods.

@return [Array<RDF::URI>]

# File lib/active_triples/properties.rb, line 65
def unregistered_predicates
  registered_preds   = registered_predicates << RDF.type
  unregistered_preds = []

  query(subject: rdf_subject) do |stmt|
    unregistered_preds << stmt.predicate unless
      registered_preds.include? stmt.predicate
  end

  unregistered_preds
end