arena 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,33 +14,40 @@ module Arena
14
14
  :connection_id, :connected_at, :connected_by_user_id, :connected_by_username
15
15
 
16
16
  def user
17
- @user ||= Arena::User.new(@attrs.dup['user'])
17
+ @user ||= Arena::User.new(@attrs['user'])
18
18
  end
19
19
 
20
20
  def _class
21
- @_class ||= @attrs.dup['class']
21
+ @_class ||= @attrs['class']
22
22
  end
23
23
 
24
24
  def _base_class
25
- @_base_class ||= @attrs.dup['base_class']
25
+ @_base_class ||= @attrs['base_class']
26
26
  end
27
27
 
28
28
  def source
29
- @source ||= Arena::Entity::Source.new(@attrs.dup['source'])
29
+ @source ||= Arena::Entity::Source.new(@attrs['source'])
30
30
  end
31
31
 
32
32
  def image
33
- @image ||= Arena::Entity::Image.new(@attrs.dup['image'])
33
+ @image ||= Arena::Entity::Image.new(@attrs['image']) if has_image?
34
34
  end
35
35
 
36
36
  def attachment
37
- @attachment ||= Arena::Entity::Attachment.new(@attrs.dup['attachment'])
37
+ @attachment ||= Arena::Entity::Attachment.new(@attrs['attachment']) if has_attachment?
38
38
  end
39
39
 
40
40
  def connections
41
41
  @connections ||= @attrs['connections'].collect { |channel| Arena::Channel.new(channel) }
42
42
  end
43
43
 
44
+ # Detect optional portions of the response
45
+ [:image, :attachment].each do |kind|
46
+ define_method "has_#{kind}?" do
47
+ !@attrs[kind.to_s].nil?
48
+ end
49
+ end
50
+
44
51
  end
45
52
 
46
53
  class Text < Block; end
@@ -11,7 +11,7 @@ module Arena
11
11
 
12
12
  %w(thumb display original).each do |method|
13
13
  define_method method do
14
- instance_variable_set("@#{method}", Arena::Entity::Version.new(@attrs.dup[method])) unless instance_variable_get "@#{method}"
14
+ instance_variable_set("@#{method}", Arena::Entity::Version.new(@attrs[method])) unless instance_variable_get "@#{method}"
15
15
  instance_variable_get "@#{method}"
16
16
  end
17
17
  end
@@ -7,7 +7,7 @@ module Arena
7
7
  attr_reader :url
8
8
 
9
9
  def provider
10
- @provider ||= Arena::Entity::Provider.new(@attrs.dup['provider'])
10
+ @provider ||= Arena::Entity::Provider.new(@attrs['provider'])
11
11
  end
12
12
  end
13
13
  end
@@ -8,7 +8,7 @@ module Arena
8
8
 
9
9
  class ChannelResults < Results
10
10
  def channels
11
- @channels ||= @attrs.dup['channels'].collect { |channel| Arena::Channel.new(channel) }
11
+ @channels ||= @attrs['channels'].collect { |channel| Arena::Channel.new(channel) }
12
12
  end
13
13
  end
14
14
  end
@@ -13,7 +13,7 @@ module Arena
13
13
  %w(user channel block).each do |method|
14
14
  define_method "#{method}s" do
15
15
  instance_variable_set("@#{method}s",
16
- @attrs.dup["#{method}s"].collect { |element| "Arena::#{method.capitalize}".constantize.new(element) }
16
+ @attrs["#{method}s"].collect { |element| "Arena::#{method.capitalize}".constantize.new(element) }
17
17
  ) unless instance_variable_get "@#{method}s"
18
18
  instance_variable_get "@#{method}s"
19
19
  end
@@ -10,7 +10,7 @@ module Arena
10
10
  :profile_id, :follower_count, :initials
11
11
 
12
12
  def _class
13
- @attrs.dup['class']
13
+ @attrs['class']
14
14
  end
15
15
  end
16
16
  end
@@ -1,5 +1,5 @@
1
1
  module Arena
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
 
4
4
  def self.version
5
5
  VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arena
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-03 00:00:00.000000000 Z
12
+ date: 2012-12-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake