Class: DribbbleBucketApi::Shot
- Inherits:
-
Object
- Object
- DribbbleBucketApi::Shot
show all
- Defined in:
- lib/dribbble_bucket_api/shot.rb
Instance Method Summary
collapse
Constructor Details
#initialize(attrs = {}) ⇒ Shot
Returns a new instance of Shot.
6
7
8
9
10
11
12
|
# File 'lib/dribbble_bucket_api/shot.rb', line 6
def initialize(attrs = {})
@attrs = attrs
unless @attrs.has_key?(:id) && @attrs[:id]
raise ArgumentError, "Shot must be initialized with an id"
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/dribbble_bucket_api/shot.rb', line 14
def method_missing(method, *args, &block)
if @attrs.has_key?(method.to_sym) && args.empty? && !block_given?
@attrs[method.to_sym]
elsif !requested_full_data? && args.empty? && !block_given?
request_full_data && send(method)
else
super
end
end
|
Instance Method Details
#request_full_data ⇒ Object
27
28
29
30
31
|
# File 'lib/dribbble_bucket_api/shot.rb', line 27
def request_full_data
@requested_full_data = true
properties = OfficialApi.new.get_shot_properties(id)
@attrs.merge!(properties)
end
|
#requested_full_data? ⇒ Boolean
33
34
35
|
# File 'lib/dribbble_bucket_api/shot.rb', line 33
def requested_full_data?
!!@requested_full_data
end
|