Class: FidorApi::Connectivity::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/fidor_api/connectivity/endpoint.rb

Defined Under Namespace

Classes: Context

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, mode, version: '1', tokenless: false) ⇒ Endpoint

Returns a new instance of Endpoint.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fidor_api/connectivity/endpoint.rb', line 6

def initialize(path, mode, version: '1', tokenless: false)
  @path = path
  @version = version
  @tokenless = tokenless

  case mode
  when :collection
    @collection = path
    @resource = "#{path}/:id"
  when :resource
    @resource = path
  else
    fail ArgumentError, "mode #{mode.inspect} must be resource or collection"
  end
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



4
5
6
# File 'lib/fidor_api/connectivity/endpoint.rb', line 4

def collection
  @collection
end

#resourceObject (readonly)

Returns the value of attribute resource.



4
5
6
# File 'lib/fidor_api/connectivity/endpoint.rb', line 4

def resource
  @resource
end

#tokenlessObject (readonly)

Returns the value of attribute tokenless.



4
5
6
# File 'lib/fidor_api/connectivity/endpoint.rb', line 4

def tokenless
  @tokenless
end

#versionObject (readonly)

Returns the value of attribute version.



4
5
6
# File 'lib/fidor_api/connectivity/endpoint.rb', line 4

def version
  @version
end

Instance Method Details

#for(object) ⇒ Object



77
78
79
# File 'lib/fidor_api/connectivity/endpoint.rb', line 77

def for(object)
  Context.new(self, object)
end