optin 0.3.0 → 0.4.0
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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/optin/version.rb +1 -1
- data/lib/optin.rb +3 -52
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f21bdfbaa6201b119504e357c84354781c1646c
|
4
|
+
data.tar.gz: e298b2bfb7dd3885554f22892f7c5581d8392847
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7c350e9f45a28e3be386d05b0d94eba9e1a2ef6c5ebfb0c34d4367c55f3579b370aa3922632e51e9f40c7cf23cb87e690b390345b43a29bc96c1059da26aedb
|
7
|
+
data.tar.gz: feefa65584ba4ea9a1254131a668c0ac644450aa17126d1cb234f40b9496e94e431424567e9b9def554bcdff7b2f322b7d6c0160fe8b1bd9785cc8746641486d
|
data/Rakefile
CHANGED
data/lib/optin/version.rb
CHANGED
data/lib/optin.rb
CHANGED
@@ -1,54 +1,5 @@
|
|
1
1
|
require 'active_record'
|
2
|
-
require "optin/version"
|
3
|
-
require 'sinatra'
|
4
|
-
require 'sinatra/activerecord'
|
5
|
-
#require 'spec/support/models.rb'
|
6
|
-
|
7
|
-
ActiveRecord::Base.extend Optin
|
8
|
-
|
9
|
-
before { content_type :json }
|
10
|
-
|
11
|
-
#create
|
12
|
-
post '/optins' do
|
13
|
-
opt_in = OptIn.new(params[:opt_in])
|
14
|
-
if opt_in.save
|
15
|
-
status 200
|
16
|
-
opt_in.to_json
|
17
|
-
else
|
18
|
-
status 500
|
19
|
-
opt_in.errors.messages.to_json
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
#update
|
24
|
-
put '/optins/:id' do
|
25
|
-
opt_in = find_optin_by_id
|
26
|
-
if opt_in
|
27
|
-
if opt_in.update_attributes(params[:opt_in])
|
28
|
-
status 200
|
29
|
-
opt_in.to_json
|
30
|
-
else
|
31
|
-
status 500
|
32
|
-
opt_in.to_json
|
33
|
-
end
|
34
|
-
else
|
35
|
-
status 404
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
#disable
|
40
|
-
put '/optins/:id/disable' do
|
41
|
-
opt_in = find_optin_by_id
|
42
|
-
if opt_in
|
43
|
-
opt_in.disable!
|
44
|
-
status 200
|
45
|
-
else
|
46
|
-
status 404
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def find_optin_by_id
|
51
|
-
OptIn.find params[:id]
|
52
|
-
end
|
53
|
-
|
54
2
|
|
3
|
+
module Optin
|
4
|
+
ActiveRecord::Base.extend Optin
|
5
|
+
end
|