active_module 0.1.0 → 0.1.2
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/README.md +7 -7
- data/lib/active_module/railitie.rb +9 -0
- data/lib/active_module/version.rb +1 -1
- data/lib/active_module.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7458cab5af87dd8a3c18157c0caa412f9a6003910f4e88c22b6989599f6282bf
|
4
|
+
data.tar.gz: 6cea9d7ee94b14c1831d956a94803ffdf36dacf3f09ed19700bf77cf1072374a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7efd1fd782f788a396ef9417fd9df4eebc29f7b5011028bcec875fa9238e53c3843d0375ec92c4b9c97fc47e89a9b666995a6767924fe7778acd1d8d896b7ab6
|
7
|
+
data.tar.gz: e4d225dece936f752153bdfde8715b2631aa7564370dbd137a2b378e89008f606ef108d2b1698650d39a758b5ab12776749cda4722ad619b7db63a7974f63ec7
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ActiveModule
|
2
2
|
|
3
|
-
*"Let's
|
3
|
+
*"Let's turn modules and classes into first-class active record values!"*
|
4
4
|
|
5
5
|
ActiveModel/ActiveRecord implementation of the Module attribute type.
|
6
6
|
|
@@ -25,7 +25,7 @@ Add to your gemfile:
|
|
25
25
|
gem 'active_module', "~>0.1"
|
26
26
|
```
|
27
27
|
|
28
|
-
|
28
|
+
If you are not using rails, just issue this command after loading active record
|
29
29
|
|
30
30
|
```ruby
|
31
31
|
ActiveModule.register!
|
@@ -109,9 +109,9 @@ my_ar_object.module_field = "MyClass::MyModule1"
|
|
109
109
|
my_ar_object.module_field #=> MyARObject::MyClass::MyModule::Module
|
110
110
|
```
|
111
111
|
|
112
|
-
|
112
|
+
## Examples
|
113
113
|
|
114
|
-
|
114
|
+
### Strategy Pattern (composition-based polymorphism)
|
115
115
|
|
116
116
|
[The Strategy design pattern](https://en.wikipedia.org/wiki/Strategy_pattern) allows composition based polymorphism. This enables runtime polymorphism (by changing the strategy in runtime),
|
117
117
|
and multiple-polymorphism (by composing an object of multiple strategies).
|
@@ -147,7 +147,7 @@ MyARObject.create!(module_field: :Strategy1).run_strategy! #=> "strategy2 called
|
|
147
147
|
```
|
148
148
|
|
149
149
|
|
150
|
-
|
150
|
+
### Rapid prototyping static domain objects
|
151
151
|
|
152
152
|
```ruby
|
153
153
|
# Provider domain Object
|
@@ -238,7 +238,7 @@ end
|
|
238
238
|
```
|
239
239
|
|
240
240
|
|
241
|
-
|
241
|
+
### Static configuration management
|
242
242
|
|
243
243
|
This example is not much different than previous one. It however stresses that the module we
|
244
244
|
refer to might be used as a source of configuration parameters that change the behaviour of
|
@@ -289,7 +289,7 @@ end
|
|
289
289
|
MyARObject.create!(provider_config: :Ebay).load_page!
|
290
290
|
```
|
291
291
|
|
292
|
-
|
292
|
+
### Rich Java/C#-like enums
|
293
293
|
This example is only to show the possibility.
|
294
294
|
This would probably benefit from using a meta programming abstraction
|
295
295
|
and there are already gems with this kind of functionality such as `enumerizable`
|
data/lib/active_module.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative "active_module/version"
|
|
4
4
|
require_relative "active_module/base"
|
5
5
|
require_relative "active_module/invalid_module_value"
|
6
6
|
require_relative "active_module/register"
|
7
|
+
require "active_module/railitie" if defined?(Rails::Railtie)
|
7
8
|
|
8
9
|
module ActiveModule
|
9
10
|
module_function
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_module
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Rolo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 1.15.0
|
47
|
-
description:
|
47
|
+
description: Let's turn modules and classes into first-class active record values!
|
48
48
|
email:
|
49
49
|
- pedrorolo@gmail.com
|
50
50
|
executables: []
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- lib/active_module/invalid_module_value.rb
|
62
62
|
- lib/active_module/module_refinement.rb
|
63
63
|
- lib/active_module/modules_index.rb
|
64
|
+
- lib/active_module/railitie.rb
|
64
65
|
- lib/active_module/register.rb
|
65
66
|
- lib/active_module/version.rb
|
66
67
|
homepage: https://github.com/pedrorolo/active_module
|
@@ -86,5 +87,5 @@ requirements: []
|
|
86
87
|
rubygems_version: 3.5.7
|
87
88
|
signing_key:
|
88
89
|
specification_version: 4
|
89
|
-
summary:
|
90
|
+
summary: ActiveModel/ActiveRecord module attribute type implementation
|
90
91
|
test_files: []
|