socialcastr 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,12 +37,12 @@ module Socialcastr
37
37
  self.class.api
38
38
  end
39
39
 
40
- def element_path
41
- self.class.element_path(self.id)
40
+ def element_path(prefix_options={})
41
+ self.class.element_path(self.id, prefix_options)
42
42
  end
43
43
 
44
- def collection_path
45
- self.class.collection_path
44
+ def collection_path(options={})
45
+ self.class.collection_path(options)
46
46
  end
47
47
 
48
48
  def to_params
@@ -69,10 +69,25 @@ module Socialcastr
69
69
  if method.to_s =~ /=$/
70
70
  @data[method_name(method.to_s.sub(/=$/,''))] = args.first
71
71
  else
72
- return @data[method_name(method)] unless @data[method_name(method)].nil?
72
+ obj = @data[method_name(method)]
73
+ unless new?
74
+ if obj.class.ancestors.include? Socialcastr::Base
75
+ obj.add_container_id(self)
76
+ end
77
+ if obj.class == Array
78
+ obj.each do |o|
79
+ o.add_container_id(self)
80
+ end
81
+ end
82
+ end
83
+ return obj
73
84
  end
74
85
  end
75
86
 
87
+ def add_container_id(container)
88
+ self.send("#{container.class.model_name.downcase}_id=", container.id)
89
+ end
90
+
76
91
  class << self
77
92
  def parse(xml="")
78
93
  source = SAX::ActiveResource.new
@@ -1,5 +1,16 @@
1
1
  module Socialcastr
2
2
  class Comment < Base
3
+ def like!
4
+ self.likes ||= []
5
+ likes << Like.parse(api.post(element_path(:message_id => self.message_id) + "/likes"))
6
+ end
7
+
8
+ def unlike!
9
+ self.likes.reject! do |l|
10
+ l.unlikable_by?(self.user_id) && api.delete(element_path(:message_id => self.mesage_id) + "/likes/#{l.id}")
11
+ end
12
+ end
13
+
3
14
  def unlikable_by?(api_id)
4
15
  self.likes.map{|l| l.unlikable_by?(api_id)}.any?
5
16
  end
@@ -1,6 +1,6 @@
1
1
  module Socialcastr
2
- class InvalidMethod < StandardError
3
- end
2
+ class InvalidMethod < StandardError; end
3
+ class InvalidAttribute < StandardError; end
4
4
  class ConnectionError < StandardError # :nodoc:
5
5
  attr_reader :response
6
6
 
@@ -1,3 +1,3 @@
1
1
  module Socialcastr
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socialcastr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-19 00:00:00.000000000 +01:00
12
+ date: 2011-07-21 00:00:00.000000000 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
17
- requirement: &2153287440 !ruby/object:Gem::Requirement
17
+ requirement: &2153397560 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0.8'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *2153287440
25
+ version_requirements: *2153397560
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec
28
- requirement: &2153315340 !ruby/object:Gem::Requirement
28
+ requirement: &2153425460 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '2.5'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2153315340
36
+ version_requirements: *2153425460
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: yard
39
- requirement: &2153314960 !ruby/object:Gem::Requirement
39
+ requirement: &2153425080 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2153314960
47
+ version_requirements: *2153425080
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: artifice
50
- requirement: &2153314500 !ruby/object:Gem::Requirement
50
+ requirement: &2153424620 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2153314500
58
+ version_requirements: *2153424620
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: nokogiri
61
- requirement: &2153314000 !ruby/object:Gem::Requirement
61
+ requirement: &2153424120 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: 1.4.4
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *2153314000
69
+ version_requirements: *2153424120
70
70
  description: A Ruby wrapper for the Socialcast REST API
71
71
  email:
72
72
  - bru@codewitch.org