Class: SPARQL::Server::Request::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/sparql-server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, schema) ⇒ Item

-


66
67
68
69
70
# File 'lib/sparql-server.rb', line 66

def initialize(object, schema)
  @schema = schema
  @object = object
  @conditions = []
end

Instance Attribute Details

#mastersObject (readonly)

Returns the value of attribute masters.



61
62
63
# File 'lib/sparql-server.rb', line 61

def masters
  @masters
end

#objectObject (readonly)

Returns the value of attribute object.



60
61
62
# File 'lib/sparql-server.rb', line 60

def object
  @object
end

Instance Method Details

#<<(triple) ⇒ Object

-


82
83
84
# File 'lib/sparql-server.rb', line 82

def <<(triple)
  @conditions << triple
end

#==(other) ⇒ Object

-


75
76
77
# File 'lib/sparql-server.rb', line 75

def ==(other)
  other.kind_of?(Item) ? @object == other.object : @object == other
end

#belongs_to?(other) ⇒ Boolean

-

Returns:

  • (Boolean)


117
118
119
120
121
122
123
124
125
126
# File 'lib/sparql-server.rb', line 117

def belongs_to?(other)
  if rdf_class.nil? or other.rdf_class.nil?
    return false
  end 
  attribute = rdf_class.has?(nil, other.rdf_class)
  if attribute.nil? or not attribute.belongs_to?
    return false
  end
  attribute.type
end

#inspectObject



128
129
130
# File 'lib/sparql-server.rb', line 128

def inspect
  @object
end

#instancesObject

-


89
90
91
# File 'lib/sparql-server.rb', line 89

def instances
  rdf_class ? rdf_class.find(:all, :conditions => find_options) : []
end

#rdf_classObject

-


110
111
112
# File 'lib/sparql-server.rb', line 110

def rdf_class
  @schema.select { |cls| cls.type == rdf_type }.first
end

#solvable?Boolean

-

Returns:

  • (Boolean)


103
104
105
# File 'lib/sparql-server.rb', line 103

def solvable?
  predefined? or rdf_type
end

#to_sql(name) ⇒ Object

-


96
97
98
# File 'lib/sparql-server.rb', line 96

def to_sql(name)
  predefined? ? value_to_sql(name) : model_to_sql(name)
end