Class: ActiveTriples::Property

Inherits:
Object
  • Object
show all
Defined in:
lib/active_triples/property.rb

Overview

A value object to encapsulate what a Property is. Instantiate with a hash of options.

Examples:

configuring a property in a schema

title_prop = ActiveTriples::Property.new(name:     :title,
                                         predicate: RDF::Vocab::DC.title)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ Property

Returns a new instance of Property.

Parameters:

  • options (Hash) (defaults to: {})

    Options for the property

Options Hash (options):

  • :name (RDF::URI)
  • :cast (Boolean)
  • :class_name (String, Class)
  • :predicate (RDF::URI)


17
18
19
20
21
# File 'lib/active_triples/property.rb', line 17

def initialize(options = {}, &block)
  self.name       = options.fetch(:name)
  self.attributes = options.except(:name)
  self.config     = block 
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



28
# File 'lib/active_triples/property.rb', line 28

attr_reader :name, :config

#nameSymbol

Returns:

  • (Symbol)


28
29
30
# File 'lib/active_triples/property.rb', line 28

def name
  @name
end

Instance Method Details

#castBoolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/active_triples/property.rb', line 32

def cast
  attributes.fetch(:cast, false)
end

#class_nameClass

Returns:

  • (Class)


38
39
40
# File 'lib/active_triples/property.rb', line 38

def class_name
  attributes[:class_name]
end

#predicateRDF::Vocabulary::Term

Returns:

  • (RDF::Vocabulary::Term)


44
45
46
# File 'lib/active_triples/property.rb', line 44

def predicate
  attributes[:predicate]
end