Class: ActiveTriples::Schema

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

Overview

Super class which provides a simple property DSL for defining property -> predicate mappings.

Examples:

defining and applying a custom schema

class MySchema < ActiveTriples::Schema
  property :title,   predicate: RDF::Vocab::DC.title
  property :creator, predicate: RDF::Vocab::DC.creator, other: :options
end

resource = Class.new { include ActiveTriples::RDFSource }
resource.apply_schema(MySchema)

Class Method Summary collapse

Class Method Details

.propertiesArray<ActiveTriples::Property>

Returns:



35
36
37
# File 'lib/active_triples/schema.rb', line 35

def properties
  @properties ||= []
end

.property(property, options) ⇒ Object

Define a property.

Parameters:

  • property (Symbol)

    The property name on the object.

  • options (Hash)

    Options for the property.

Options Hash (options):

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

    The predicate to map the property to.

See Also:



29
30
31
# File 'lib/active_triples/schema.rb', line 29

def property(property, options)
  properties << Property.new(options.merge(:name => property))
end