respond_with_service 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b9568f5537b49da76900091f13e60ac2f60a0550
4
+ data.tar.gz: 34404b4d1155c763c61d0cd978572430e7dda1d0
5
+ SHA512:
6
+ metadata.gz: bcd19ea83763ce320474eb8fbe58bd8fe4a8ba94e12af5f08837261c94c0c8a8d6ea1fe6ab9275d92d9652a6e6094506befddcc39217a1390f6daaaaabc07bc9
7
+ data.tar.gz: 44f680601cfd67c49fe8f87b910a0117f79b849f79f960d1305d02c5db8807b2b1237b2f92cfa92a812bea2dcaedfc8041f5e3b5b0b81037097d64f68424c95b
data/..gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require './version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "."
8
+ spec.version = .::VERSION
9
+ spec.authors = ["Pierre-Alexandre Piarulli"]
10
+ spec.email = ["go@rubyrock.me"]
11
+ spec.summary = %q{TODO: Write a short summary. Required.}
12
+ spec.description = %q{TODO: Write a longer description. Optional.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ end
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in respond_with_service.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Pierre-Alexandre Piarulli
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ respond_with_service
2
+ ====================
3
+
4
+ i use it in active admin (respond with a service instaded of a model)
5
+
6
+
7
+ some screen shot
8
+
9
+ before i do like this
10
+ ====================
11
+
12
+ and ask myself a lots of questions.
13
+
14
+ ![alt tag](https://raw.github.com/ranska/respond_with_service/master/readme_assets/images/respond_with_service.png)
15
+
16
+
17
+ now i do like this
18
+ ====================
19
+
20
+ and because it's more clean...
21
+ new question come ;) haaa I.T.
22
+
23
+
24
+ ![alt tag](https://raw.github.com/ranska/respond_with_service/master/readme_assets/images/respond_with_service_001.png)
25
+
26
+ Why
27
+ ====================
28
+
29
+ Sometime i love use conserns sometime i love to use services.
30
+
31
+ why...
32
+ [ because we can ]( https://www.youtube.com/watch?v=WlGIxof7w5I)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/..rb ADDED
@@ -0,0 +1,5 @@
1
+ require "./version"
2
+
3
+ module .
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module RespondWithService
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,57 @@
1
+ require "respond_with_service/version"
2
+
3
+ module RespondWithService
4
+ # Your code goes here...
5
+ end
6
+
7
+ module AccountModuleService
8
+ def self.included base
9
+ base.send :include, InstanceMethods
10
+ base.extend ClassMethods
11
+ end
12
+
13
+ module InstanceMethods
14
+ private
15
+
16
+ def redirect_to_after_call service, model_instance, fail_path
17
+ if service.call
18
+ flash[:notice] = 'Successfully update'
19
+ #redirect_to [:admin, :accounts]
20
+ redirect_to [fail_path, :admin, model_instance]
21
+ else
22
+ # TODO notice errors ap create_account_service.errors
23
+ redirect_to [fail_path, :admin, model_instance]
24
+ end
25
+ end
26
+ end
27
+
28
+ module ClassMethods
29
+ def respond_with_service class_name, conf
30
+ conf[:actions].each do |action|
31
+ # TODO model can be conf
32
+ model = Object.const_get class_name
33
+ #service = Object.const_get "#{class_name}Service"
34
+ define_method action do
35
+ case action
36
+ when :create
37
+ model_instance = model.new
38
+ fail_path = :new
39
+ service = Object.const_get(class_name)
40
+ .const_get "Create#{class_name}Service"
41
+ when :update
42
+ model_instance = model.find params[:id]
43
+ fail_path = :edit
44
+ service = Object.const_get(class_name)
45
+ .const_get "Update#{class_name}Service"
46
+ end
47
+ service_instance = service.new params, model_instance
48
+ redirect_to_after_call service_instance,
49
+ model_instance, fail_path
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ class ActiveAdmin::ResourceController
57
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module .
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'respond_with_service/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "respond_with_service"
8
+ spec.version = RespondWithService::VERSION
9
+ spec.authors = ["Pierre-Alexandre Piarulli"]
10
+ spec.email = ["go@rubyrock.me"]
11
+ spec.summary = %q{like respond_with but with service.}
12
+ spec.description = %q{first write for none standar database + active_admin app and then open as a gem}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: respond_with_service
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Pierre-Alexandre Piarulli
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: first write for none standar database + active_admin app and then open
42
+ as a gem
43
+ email:
44
+ - go@rubyrock.me
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ..gemspec
50
+ - .gitignore
51
+ - Gemfile
52
+ - LICENSE
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - lib/..rb
57
+ - lib/respond_with_service.rb
58
+ - lib/respond_with_service/version.rb
59
+ - lib/version.rb
60
+ - readme_assets/images/respond_with_service.png
61
+ - readme_assets/images/respond_with_service_001.png
62
+ - respond_with_service.gemspec
63
+ homepage: ''
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.0.3
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: like respond_with but with service.
87
+ test_files: []