motion-rails-model 0.0.1.2 → 0.0.1.3

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.
@@ -38,6 +38,13 @@ module RM
38
38
  end
39
39
  end
40
40
 
41
+ def destory(url="#{self.class.to_s.downcase}/#{self.id}", &block)
42
+ data = { credentials: {username: @@username, password: @@password}}
43
+ connect(url, data, :delete) do |result|
44
+ block.call(result)
45
+ end
46
+ end
47
+
41
48
  def self.set_url(url)
42
49
  @@url = url
43
50
  end
@@ -66,11 +73,15 @@ module RM
66
73
  def connect(url, data, http_verb, &block)
67
74
  BW::HTTP.send(http_verb, "#{@@url}#{url}", data) do |response|
68
75
  if response.ok?
69
- json = BW::JSON.parse(response.body.to_str)
70
- if json.instance_of?(Array)
71
- block.call(json.map {|y| self.class.new(y) })
76
+ if response.body.nil?
77
+ block.call(response.status_code)
72
78
  else
73
- block.call(self.class.new(json))
79
+ json = BW::JSON.parse(response.body.to_str)
80
+ if json.instance_of?(Array)
81
+ block.call(json.map {|y| self.class.new(y) })
82
+ else
83
+ block.call(self.class.new(json))
84
+ end
74
85
  end
75
86
  else
76
87
  block.call(nil)
@@ -1,5 +1,5 @@
1
1
  module RM
2
2
  class Model
3
- VERSION = "0.0.1.2"
3
+ VERSION = "0.0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-rails-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.2
4
+ version: 0.0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: