Class: Evri::Relation

Inherits:
Object
  • Object
show all
Defined in:
lib/evri/relation.rb

Overview

Represents a relation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Relation

:nodoc:



5
6
7
8
9
10
# File 'lib/evri/relation.rb', line 5

def initialize json # :nodoc:
  @name = json[:name]
  @href = json[:href]
  @type = json[:type]
  @entities = []
end

Instance Attribute Details

#hrefObject

Returns the value of attribute href.



4
5
6
# File 'lib/evri/relation.rb', line 4

def href
  @href
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/evri/relation.rb', line 4

def name
  @name
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/evri/relation.rb', line 4

def type
  @type
end

Instance Method Details

#entitiesObject

Returns the entities in this relation.



13
14
15
16
17
18
19
20
21
# File 'lib/evri/relation.rb', line 13

def entities
  return @entities unless @entities.empty?
  json = Evri.query(:type => :uri, :query => @href)
  @entities = 
    Entity.create_many do
      json["relations/relation/targets/entity"]
    end
  @entities
end