Class: ResoTransport::Resource

Inherits:
Struct
  • Object
show all
Defined in:
lib/reso_transport/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clientObject

Returns the value of attribute client

Returns:

  • (Object)

    the current value of client



2
3
4
# File 'lib/reso_transport/resource.rb', line 2

def client
  @client
end

#entity_setObject

Returns the value of attribute entity_set

Returns:

  • (Object)

    the current value of entity_set



2
3
4
# File 'lib/reso_transport/resource.rb', line 2

def entity_set
  @entity_set
end

Instance Method Details

#entity_typeObject



24
25
26
# File 'lib/reso_transport/resource.rb', line 24

def entity_type
  @entity_type ||= schema.entity_types.detect {|et| et.name == entity_set.entity_type }
end

#expandableObject



20
21
22
# File 'lib/reso_transport/resource.rb', line 20

def expandable
  entity_type.navigation_properties
end

#get(params) ⇒ Object



40
41
42
43
44
# File 'lib/reso_transport/resource.rb', line 40

def get(params)
  client.connection.get(name, params) do |req|
    req.headers['Accept'] = 'application/json'
  end
end

#inspectObject



50
51
52
# File 'lib/reso_transport/resource.rb', line 50

def inspect
  to_s
end

#mdObject



32
33
34
# File 'lib/reso_transport/resource.rb', line 32

def md
  client.
end

#nameObject



8
9
10
# File 'lib/reso_transport/resource.rb', line 8

def name
  entity_set.name
end

#parse(results) ⇒ Object



36
37
38
# File 'lib/reso_transport/resource.rb', line 36

def parse(results)
  results.map {|r| entity_type.parse(r) }
end

#propertiesObject



16
17
18
# File 'lib/reso_transport/resource.rb', line 16

def properties
  entity_type.properties
end

#property(name) ⇒ Object



12
13
14
# File 'lib/reso_transport/resource.rb', line 12

def property(name)
  properties.detect {|p| p.name == name }
end

#queryObject



4
5
6
# File 'lib/reso_transport/resource.rb', line 4

def query
  Query.new(self)
end

#schemaObject



28
29
30
# File 'lib/reso_transport/resource.rb', line 28

def schema
  @schema ||= md.schemas.detect {|s| s.namespace == entity_set.schema }
end

#to_sObject



46
47
48
# File 'lib/reso_transport/resource.rb', line 46

def to_s
  %(#<ResoTransport::Resource entity_set="#{name}", schema="#{schema&.namespace}">)
end