Class: Box::Comment
- Inherits:
-
Object
show all
- Defined in:
- lib/box/comment.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(api, data) ⇒ Comment
Create a new comment object for a file.
24
25
26
27
|
# File 'lib/box/comment.rb', line 24
def initialize(api, data)
@api = api
@data = data
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'lib/box/comment.rb', line 31
def method_missing(sym, *args, &block)
sym = sym.to_s
return @data[sym] if @data.key?(sym)
super
end
|
Class Method Details
.create(api, comments) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/box/comment.rb', line 3
def self.create(api, )
if
= [ ] if .class == Hash
.collect do ||
= .delete('reply_comments')
['id'] = .delete('comment_id')
['comments'] = self.create(api, ['item']) if
Comment.new(api, )
end
else
Array.new
end
end
|
Instance Method Details
#delete ⇒ Object
44
45
46
47
48
|
# File 'lib/box/comment.rb', line 44
def delete
@api.(id)
true
end
|
#id ⇒ Object
29
|
# File 'lib/box/comment.rb', line 29
def id; @data['id']; end
|
#respond_to?(sym) ⇒ Boolean
40
41
42
|
# File 'lib/box/comment.rb', line 40
def respond_to?(sym)
@data.key?(sym.to_s) or super
end
|