Class: LinkedRails::Widget

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, Model
Defined in:
app/models/linked_rails/widget.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

#build_child, #singular_resource?

Methods included from Model::Serialization

#preview_includes, #show_includes

Methods included from Model::Iri

#anonymous_iri, #anonymous_iri?, #iri_opts, #rdf_type, #reload, #root_relative_iri, #route_fragment

Methods included from Model::Enhancements

#enhanced_with?

Methods included from Model::Dirty

#previous_changes_by_predicate, #previously_changed_relations

Methods included from Model::Collections

#collection_for, #parent_collections

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



9
10
11
# File 'app/models/linked_rails/widget.rb', line 9

def parent
  @parent
end

#resources=(value) ⇒ Object (writeonly)

Sets the attribute resources

Parameters:

  • value

    the value to set the attribute resources to.



8
9
10
# File 'app/models/linked_rails/widget.rb', line 8

def resources=(value)
  @resources = value
end

#sizeObject



30
31
32
# File 'app/models/linked_rails/widget.rb', line 30

def size
  @size || 1
end

#topologyObject

Returns the value of attribute topology.



9
10
11
# File 'app/models/linked_rails/widget.rb', line 9

def topology
  @topology
end

Class Method Details

.iriObject



46
47
48
# File 'app/models/linked_rails/widget.rb', line 46

def iri
  Vocab.ontola[:Widget]
end

.preview_includesObject



50
51
52
# File 'app/models/linked_rails/widget.rb', line 50

def preview_includes
  %i[resource_sequence property_shapes]
end

Instance Method Details

#iri(_opts = {}) ⇒ Object



11
12
13
# File 'app/models/linked_rails/widget.rb', line 11

def iri(_opts = {})
  @iri ||= RDF::Node.new
end

#property_shapesObject



15
16
17
18
19
# File 'app/models/linked_rails/widget.rb', line 15

def property_shapes
  resource_sequence

  @property_shapes || {}
end

#resource_sequenceObject



21
22
23
24
25
26
27
28
# File 'app/models/linked_rails/widget.rb', line 21

def resource_sequence
  @resource_sequence ||=
    LinkedRails::Sequence.new(
      @resources.map { |iri, predicate| predicate.present? ? property_shape(iri, predicate).iri : RDF::URI(iri) },
      parent: self,
      scope: false
    )
end