Class: ActiveTriples::NodeConfig

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

Overview

Configuration for properties

Defined Under Namespace

Classes: IndexObject

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(term, predicate, opts = {}) {|config| ... } ⇒ NodeConfig

Returns a new instance of NodeConfig.

Parameters:

  • term (Symbol)
  • predicate (RDF::URI)
  • opts (Hash<Symbol, Object>) (defaults to: {})

Options Hash (opts):

  • :class_name (String, Class)
  • :class_name (String, Class)

Yields:

  • yields self to the block

Yield Parameters:



31
32
33
34
35
36
37
38
# File 'lib/active_triples/node_config.rb', line 31

def initialize(term, predicate, opts={})
  self.term = term
  self.predicate = predicate
  self.class_name = opts.delete(:class_name) { nil }
  self.cast = opts.delete(:cast) { true }
  @opts = opts
  yield(self) if block_given?
end

Instance Attribute Details

#behaviorsEnumerator<Symbol>

Returns:

  • (Enumerator<Symbol>)


20
# File 'lib/active_triples/node_config.rb', line 20

attr_accessor :predicate, :term, :class_name, :type, :behaviors, :cast

#castBoolean

Returns:

  • (Boolean)


20
# File 'lib/active_triples/node_config.rb', line 20

attr_accessor :predicate, :term, :class_name, :type, :behaviors, :cast

#class_nameClass, String

Returns:

  • (Class, String)


20
# File 'lib/active_triples/node_config.rb', line 20

attr_accessor :predicate, :term, :class_name, :type, :behaviors, :cast

#predicateRDF::URI

Returns:

  • (RDF::URI)


20
21
22
# File 'lib/active_triples/node_config.rb', line 20

def predicate
  @predicate
end

#termSymbol

Returns:

  • (Symbol)


20
# File 'lib/active_triples/node_config.rb', line 20

attr_accessor :predicate, :term, :class_name, :type, :behaviors, :cast

#typeSymbol

Returns:

  • (Symbol)


20
# File 'lib/active_triples/node_config.rb', line 20

attr_accessor :predicate, :term, :class_name, :type, :behaviors, :cast

Instance Method Details

#[](value) ⇒ Object

Returns the attribute or option represented by the symbol.

Parameters:

  • value (#to_sym)

Returns:

  • (Object)

    the attribute or option represented by the symbol



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

def [](value)
  value = value.to_sym
  self.respond_to?(value) ? self.public_send(value) : @opts[value]
end

#with_index {|index| ... } ⇒ Object

Yields:

  • yields an index configuration object

Yield Parameters:



64
65
66
67
68
69
70
# File 'lib/active_triples/node_config.rb', line 64

def with_index(&block)
  # needed for solrizer integration
  iobj = IndexObject.new
  yield iobj
  self.type = iobj.data_type
  self.behaviors = iobj.behaviors
end