Class: Axel::Configurations::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/axel/configurations/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, service, options = {}) ⇒ Resource

Returns a new instance of Resource.



9
10
11
12
13
14
# File 'lib/axel/configurations/resource.rb', line 9

def initialize(name, service, options = {})
  @name = name.to_s.singularize
  @service = service
  @attributes = options[:attributes] || []
  @path = options[:path] # If nil it will try to build URL from name and service
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



6
7
8
# File 'lib/axel/configurations/resource.rb', line 6

def attributes
  @attributes
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#pathObject



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

def path
  @path || name.pluralize
end

#serviceObject (readonly)

Returns the value of attribute service.



5
6
7
# File 'lib/axel/configurations/resource.rb', line 5

def service
  @service
end

Instance Method Details

#base_urlObject



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

def base_url
  service.url
end

#full_urlObject



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

def full_url
  URI.join(base_url, path).to_s
end