Class: Sifterology::Resource

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

Direct Known Subclasses

Commit, CommitFactory, Project, ProjectFactory

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session, factory = nil) ⇒ Resource

Returns a new instance of Resource.



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

def initialize(session, factory=nil)
  @session = session
  @factory = factory
end

Instance Attribute Details

#factoryObject (readonly)

Returns the value of attribute factory.



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

def factory
  @factory
end

#last_requestObject

Returns the value of attribute last_request.



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

def last_request
  @last_request
end

#sessionObject (readonly)

Returns the value of attribute session.



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

def session
  @session
end

Class Method Details

.sifter_attrs(*args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/sifterology/resource.rb', line 8

def self.sifter_attrs(*args)
  args.each do |name|
    define_method(name) do
      instance_variable_get("@_sifter_#{name}")
    end
    
    define_method("#{name}=") do |value|
      instance_variable_set("@_sifter_#{name}", value)
    end
  end
end

Instance Method Details

#attributes=(hash) ⇒ Object



41
42
43
44
45
# File 'lib/sifterology/resource.rb', line 41

def attributes=(hash)
  hash.each_pair do |name, value|
    instance_variable_set("@_sifter_#{ name }", value)
  end
end

#delete(*args) ⇒ Object



37
38
39
# File 'lib/sifterology/resource.rb', line 37

def delete(*args)
  request(:delete, *args)
end

#get(*args) ⇒ Object



25
26
27
# File 'lib/sifterology/resource.rb', line 25

def get(*args)
  request(:get, *args)
end

#local_attributes=(hash) ⇒ Object



47
48
49
50
51
# File 'lib/sifterology/resource.rb', line 47

def local_attributes=(hash)
  hash.each_pair do |name, value|
    instance_variable_set("@#{ name }", value)
  end
end

#post(*args) ⇒ Object



29
30
31
# File 'lib/sifterology/resource.rb', line 29

def post(*args)
  request(:post, *args)
end

#put(*args) ⇒ Object



33
34
35
# File 'lib/sifterology/resource.rb', line 33

def put(*args)
  request(:put, *args)
end