Class: ResourceKit::Resource

Inherits:
Object
  • Object
show all
Extended by:
InheritableAttribute
Defined in:
lib/resource_kit/resource.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from InheritableAttribute

inherit, inheritable_attr

Constructor Details

#initialize(connection: nil, scope: nil) ⇒ Resource

Returns a new instance of Resource.



10
11
12
13
# File 'lib/resource_kit/resource.rb', line 10

def initialize(connection: nil, scope: nil)
  @connection = connection
  @scope = scope
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



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

def connection
  @connection
end

#scopeObject (readonly)

Returns the value of attribute scope.



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

def scope
  @scope
end

Class Method Details

.resources(&block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/resource_kit/resource.rb', line 15

def self.resources(&block)
  self._resources ||= ResourceCollection.new

  if block_given?
    self._resources.instance_eval(&block)
    MethodFactory.construct(self, self._resources)
  end

  self._resources
end

Instance Method Details

#action(name) ⇒ Object



26
27
28
# File 'lib/resource_kit/resource.rb', line 26

def action(name)
  _resources.find_action(name)
end

#action_and_connection(action_name) ⇒ Object



30
31
32
# File 'lib/resource_kit/resource.rb', line 30

def action_and_connection(action_name)
  ActionConnection.new(action(action_name), connection)
end