Class: RaindropIo::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/raindrop_io/base.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}) ⇒ Base
Returns a new instance of Base.
22
23
24
25
|
# File 'lib/raindrop_io/base.rb', line 22
def initialize(attributes = {})
initialize_attributes(attributes)
@attributes = attributes
end
|
Instance Attribute Details
#attributes ⇒ Object
21
22
23
|
# File 'lib/raindrop_io/base.rb', line 21
def attributes
@attributes
end
|
Class Method Details
.delete(path, options = {}) ⇒ Object
16
17
18
|
# File 'lib/raindrop_io/base.rb', line 16
def delete(path, options = {})
RaindropIo::Api.delete(path, options)
end
|
.get(path, options = {}) ⇒ Object
4
5
6
|
# File 'lib/raindrop_io/base.rb', line 4
def get(path, options = {})
RaindropIo::Api.get(path, options)
end
|
.post(path, options = {}) ⇒ Object
12
13
14
|
# File 'lib/raindrop_io/base.rb', line 12
def post(path, options = {})
RaindropIo::Api.post(path, options)
end
|
.put(path, options = {}) ⇒ Object
8
9
10
|
# File 'lib/raindrop_io/base.rb', line 8
def put(path, options = {})
RaindropIo::Api.put(path, options)
end
|
Instance Method Details
#initialize_attributes(attributes) ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/raindrop_io/base.rb', line 27
def initialize_attributes(attributes)
attributes.each do |key, value|
variable_name = key.to_sym
instance_variable_set(:"@#{variable_name}", value)
unless self.class.method_defined?(variable_name)
self.class.send(:attr_accessor, variable_name)
end
end
end
|
#to_h ⇒ Object
41
42
43
|
# File 'lib/raindrop_io/base.rb', line 41
def to_h
to_hash
end
|
#to_hash ⇒ Object
37
38
39
|
# File 'lib/raindrop_io/base.rb', line 37
def to_hash
@attributes
end
|
#to_json(*args) ⇒ Object
45
46
47
|
# File 'lib/raindrop_io/base.rb', line 45
def to_json(*args)
@attributes.to_json(*args)
end
|