faat 0.1.4 → 0.1.5
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 +8 -8
- data/faat.gemspec +1 -0
- data/lib/faat.rb +3 -1
- data/lib/faat/faat_object/faat_object.rb +60 -0
- data/lib/faat/resources/base.rb +1 -54
- data/lib/faat/services/base.rb +13 -0
- data/lib/faat/version.rb +1 -1
- data/lib/generators/faat/services/services_generator.rb +24 -0
- data/lib/generators/faat/services/templates/service_template.rb +11 -0
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzA0NzY2ODdlMDE3ZGIwNzFkNjllYWJhZjQwNTMxMTFhMTBiYWEyNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzZmMmNjZGU1ODljMWVhOTYwNGI3NGMwNjliNmVhNGYzNjNhY2U4Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGM4NjI5YTI1ZDJhNDQwMGNiNTgwY2RiMDFiMzUyNjdlNDY3MjAzMjM5YjNl
|
10
|
+
ODQ5M2JkMDJlNWViNmUzZWM1MmQyMTYzNzNhMjA1MDVhMmYzMWIzYjM0YWIx
|
11
|
+
ZDFiYTYwNDc5YjIwMDE1Njk3MjFkOGRjNzc4M2YyNzk2MDA1Yjg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWUxNmY1NzkwMmUxY2NjODUzNGFmYzM5M2ZmOTQ3M2FiZDEwYjA1ODg0NjY0
|
14
|
+
ZDUyMGEzNzQ0NTZiOTYyZGY2Y2E2OThiODE4ZjFiMzJiM2ZiMmQ3ZWRlZGQ2
|
15
|
+
YzA4NDNmNTg0ZGNhNDg2YjFlYmM3MjViMWUxZDJlZjBkYjRkZjU=
|
data/faat.gemspec
CHANGED
data/lib/faat.rb
CHANGED
@@ -23,11 +23,13 @@
|
|
23
23
|
|
24
24
|
require 'rails'
|
25
25
|
require 'faat/version'
|
26
|
-
require 'faat/
|
26
|
+
require 'faat/faat_object/faat_object'
|
27
27
|
require 'faat/helpers/string'
|
28
28
|
require 'active_support/inflector'
|
29
29
|
|
30
30
|
# root gem module
|
31
31
|
module Faat
|
32
32
|
autoload :Resources, 'faat/resources/base'
|
33
|
+
autoload :Forms, 'faat/forms/base'
|
34
|
+
autoload :Services, 'faat/services/base'
|
33
35
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# root module Faat
|
2
|
+
module Faat
|
3
|
+
# base FaatClass, in this class made,
|
4
|
+
# by the main logic of this class of objects,
|
5
|
+
# inherited basic resources and services
|
6
|
+
class FaatObject
|
7
|
+
def initialize(resource)
|
8
|
+
# setup resource name for accessing from other methods
|
9
|
+
@resource_name = resource.class.name.underscore
|
10
|
+
|
11
|
+
# setup :attr_accessor for resource attributes
|
12
|
+
self.class.send(:attr_accessor, resource.class.name.underscore)
|
13
|
+
# setup :class_name for resource class
|
14
|
+
self.class.class_eval { @class_name = resource.class.name }
|
15
|
+
instance_variable_set("@#{resource.class.name.underscore}", resource)
|
16
|
+
end
|
17
|
+
|
18
|
+
# initialize :method_missing for ActiveRecord methods
|
19
|
+
# like :save, :valid?, :destroy and others
|
20
|
+
|
21
|
+
def method_missing(name, *attr, &block)
|
22
|
+
# getting resource by instance variable :resource_name
|
23
|
+
resource.send(name, *attr, &block) || super
|
24
|
+
end
|
25
|
+
|
26
|
+
# initialize :respond_to_missing? method for working with
|
27
|
+
# ActiveRecord instance methods
|
28
|
+
|
29
|
+
def respond_to_missing?(name, include_private = false)
|
30
|
+
# getting resource by instance variable :resource_name,
|
31
|
+
# for :respond_to? method
|
32
|
+
resource.respond_to?(name) || super
|
33
|
+
end
|
34
|
+
|
35
|
+
# add class methods form resource class
|
36
|
+
class << self
|
37
|
+
# singleton method :method_missing
|
38
|
+
def method_missing(name, *attr, &block)
|
39
|
+
# initialize :method_missing for accessing for
|
40
|
+
# ActiveRecord model class_methods
|
41
|
+
class_eval do
|
42
|
+
@class_name.constantize.send(name, *attr, &block) || super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def respond_to_missing?(name, include_private = false)
|
47
|
+
# getting respond_to? access to ActiveRecord model class_methods
|
48
|
+
class_eval do
|
49
|
+
@class_name.constantize.respond_to?(name) || super
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def resource
|
57
|
+
instance_variable_get("@#{@resource_name}")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/faat/resources/base.rb
CHANGED
@@ -3,66 +3,13 @@ module Faat
|
|
3
3
|
# Faat::Resources resources module
|
4
4
|
module Resources
|
5
5
|
# Faat::Resources::Base default resource class
|
6
|
-
class Base
|
6
|
+
class Base < Faat::FaatObject
|
7
7
|
# Your classes must inherited from this Base class
|
8
8
|
# for removing all business logic from models classes,
|
9
9
|
# and controllers
|
10
10
|
# Right now you can use one resources for one model,
|
11
11
|
|
12
12
|
# TODO: implement resources logic for working with coup of models
|
13
|
-
|
14
|
-
def initialize(resource)
|
15
|
-
# setup resource name for accessing from other methods
|
16
|
-
@resource_name = resource.class.name.underscore
|
17
|
-
|
18
|
-
# setup :attr_accessor for resource attributes
|
19
|
-
self.class.send(:attr_accessor, resource.class.name.underscore)
|
20
|
-
# setup :class_name for resource class
|
21
|
-
self.class.class_eval { @class_name = resource.class.name }
|
22
|
-
instance_variable_set("@#{resource.class.name.underscore}", resource)
|
23
|
-
end
|
24
|
-
|
25
|
-
# initialize :method_missing for ActiveRecord methods
|
26
|
-
# like :save, :valid?, :destroy and others
|
27
|
-
|
28
|
-
def method_missing(name, *attr, &block)
|
29
|
-
# getting resource by instance variable :resource_name
|
30
|
-
resource.send(name, *attr, &block) || super
|
31
|
-
end
|
32
|
-
|
33
|
-
# initialize :respond_to_missing? method for working with
|
34
|
-
# ActiveRecord instance methods
|
35
|
-
|
36
|
-
def respond_to_missing?(name, include_private = false)
|
37
|
-
# getting resource by instance variable :resource_name,
|
38
|
-
# for :respond_to? method
|
39
|
-
resource.respond_to?(name) || super
|
40
|
-
end
|
41
|
-
|
42
|
-
# add class methods form resource class
|
43
|
-
class << self
|
44
|
-
# singleton method :method_missing
|
45
|
-
def method_missing(name, *attr, &block)
|
46
|
-
# initialize :method_missing for accessing for
|
47
|
-
# ActiveRecord model class_methods
|
48
|
-
class_eval do
|
49
|
-
@class_name.constantize.send(name, *attr, &block) || super
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def respond_to_missing?(name, include_private = false)
|
54
|
-
# getting respond_to? access to ActiveRecord model class_methods
|
55
|
-
class_eval do
|
56
|
-
@class_name.constantize.respond_to?(name) || super
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
private
|
62
|
-
|
63
|
-
def resource
|
64
|
-
instance_variable_get("@#{@resource_name}")
|
65
|
-
end
|
66
13
|
end
|
67
14
|
end
|
68
15
|
end
|
data/lib/faat/version.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'generators/faat'
|
2
|
+
require 'rails/generators/base'
|
3
|
+
|
4
|
+
module Faat
|
5
|
+
module Generators
|
6
|
+
class ServicesGenerator < Base
|
7
|
+
argument :service_name, type: :string, default: 'app', banner: 'service_name'
|
8
|
+
|
9
|
+
def create_service
|
10
|
+
template "service_template.rb", "app/services/#{file_name}_service.rb"
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def file_name
|
16
|
+
service_name.underscore
|
17
|
+
end
|
18
|
+
|
19
|
+
def class_name
|
20
|
+
service_name.downcase.capitalize
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= '# default generated template' %>
|
2
|
+
|
3
|
+
<%= "# for using with model resource, initialize #{service_name}Service" %>
|
4
|
+
<%= "# #{service_name}Service.new( ModelClassName.new )" %>
|
5
|
+
<%= "# or with instance variable #{service_name}Service.new(@model_class_name)" %>
|
6
|
+
|
7
|
+
class <%= service_name %>Service < Faat::Service::Base
|
8
|
+
|
9
|
+
# add your business logic here
|
10
|
+
|
11
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nazarii Sheremet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 3.4.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: Gem Faat kills your fat models.
|
112
126
|
email:
|
113
127
|
- xo8bit@gmail.com
|
@@ -126,15 +140,19 @@ files:
|
|
126
140
|
- bin/setup
|
127
141
|
- faat.gemspec
|
128
142
|
- lib/faat.rb
|
143
|
+
- lib/faat/faat_object/faat_object.rb
|
129
144
|
- lib/faat/forms/base.rb
|
130
145
|
- lib/faat/helpers/string.rb
|
131
146
|
- lib/faat/resources/base.rb
|
147
|
+
- lib/faat/services/base.rb
|
132
148
|
- lib/faat/version.rb
|
133
149
|
- lib/generators/faat.rb
|
134
150
|
- lib/generators/faat/forms/forms_generator.rb
|
135
151
|
- lib/generators/faat/forms/templates/form_template.rb
|
136
152
|
- lib/generators/faat/resources/resources_generator.rb
|
137
153
|
- lib/generators/faat/resources/templates/resource_template.rb
|
154
|
+
- lib/generators/faat/services/services_generator.rb
|
155
|
+
- lib/generators/faat/services/templates/service_template.rb
|
138
156
|
homepage: https://github.com/xo8bit/faat
|
139
157
|
licenses:
|
140
158
|
- MIT
|