Class: StackExchange::StackOverflow::Base
- Inherits:
-
Object
- Object
- StackExchange::StackOverflow::Base
show all
- Extended by:
- Forwardable
- Defined in:
- lib/pilha/stack_overflow/base.rb
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(hash) ⇒ Base
Returns a new instance of Base.
33
34
35
|
# File 'lib/pilha/stack_overflow/base.rb', line 33
def initialize(hash)
@struct = OpenStruct.new hash
end
|
Class Attribute Details
.api_methods ⇒ Object
Returns the value of attribute api_methods.
7
8
9
|
# File 'lib/pilha/stack_overflow/base.rb', line 7
def api_methods
@api_methods
end
|
Class Method Details
.parse_with_class(hash, key, klass) ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/pilha/stack_overflow/base.rb', line 14
def parse_with_class(hash, key, klass)
case hash[key]
when Hash
hash[key] = klass.new(hash[key])
when Array
hash[key] = hash[key].map { |value| klass.new(value) }
end
end
|
.request(path_pattern, id, options) ⇒ Object
23
24
25
26
|
# File 'lib/pilha/stack_overflow/base.rb', line 23
def request(path_pattern, id, options)
options.merge! :id => id if id
parse client.request(path_pattern, options)
end
|
.setup_delegators(*delegators) ⇒ Object
9
10
11
12
|
# File 'lib/pilha/stack_overflow/base.rb', line 9
def setup_delegators(*delegators)
@api_methods = delegators
def_delegators *delegators
end
|
Instance Method Details
#api_methods ⇒ Object
37
38
39
|
# File 'lib/pilha/stack_overflow/base.rb', line 37
def api_methods
self.class.api_methods
end
|