Class: OpenSesame::Github::Collection
- Inherits:
-
Base
- Object
- Base
- OpenSesame::Github::Collection
show all
- Includes:
- Enumerable
- Defined in:
- lib/opensesame/github/collection.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#attributes
Instance Method Summary
collapse
Methods inherited from Base
#==, #get, #initialize, lazy_attr_reader
Instance Attribute Details
#member_class ⇒ Object
Returns the value of attribute member_class.
7
8
9
|
# File 'lib/opensesame/github/collection.rb', line 7
def member_class
@member_class
end
|
#url ⇒ Object
Returns the value of attribute url.
7
8
9
|
# File 'lib/opensesame/github/collection.rb', line 7
def url
@url
end
|
Instance Method Details
#each(&block) ⇒ Object
29
30
31
|
# File 'lib/opensesame/github/collection.rb', line 29
def each(&block)
members.each(&block)
end
|
#fetch ⇒ Object
17
18
19
|
# File 'lib/opensesame/github/collection.rb', line 17
def fetch
reset(get(url))
end
|
#find(id) ⇒ Object
13
14
15
|
# File 'lib/opensesame/github/collection.rb', line 13
def find(id)
members.detect { |member| member.id == id }
end
|
#members ⇒ Object
9
10
11
|
# File 'lib/opensesame/github/collection.rb', line 9
def members
@members ||= []
end
|
#reset(member_attrs) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/opensesame/github/collection.rb', line 21
def reset(member_attrs)
@members = [].tap do |member_set|
member_attrs.map do |attrs|
member_set << member_class.new(attrs)
end
end
end
|
#size ⇒ Object
33
34
35
|
# File 'lib/opensesame/github/collection.rb', line 33
def size
members.size
end
|