active_module 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2bfc44bc97bbd3905636170057b010c4e2bd7cdb04bb749dcb0951c4ca7ae21
4
- data.tar.gz: 22bec343c43a708452e724d648c7520dd923459d197c426acf796ca983163965
3
+ metadata.gz: 7458cab5af87dd8a3c18157c0caa412f9a6003910f4e88c22b6989599f6282bf
4
+ data.tar.gz: 6cea9d7ee94b14c1831d956a94803ffdf36dacf3f09ed19700bf77cf1072374a
5
5
  SHA512:
6
- metadata.gz: 930ab5f0f7998773628a5d63fe58108b2cd9aaa430c0c168b49f08152dd965c06cb12439a83eade0a8ba929782bca3522c2e0a3f6506aa8883439e2e1c84962e
7
- data.tar.gz: 22aa9eb2fd4d4c9a3d74671eee90f22c91aef2eb0f2b6591729fe15cad177c25d8a0a0ed17ac16b14f28f499d3f206bfe87e644115cf3f0384b3000adc7cd630
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 make `Modules` and `Classes` first-class values in active record!"*
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
- Add to a rails initializer, such as `intializers/types.rb`
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
- ### Examples
112
+ ## Examples
113
113
 
114
- #### Strategy Pattern (composition-based polymorphism)
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
- #### Rapid prototyping static domain objects
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
- #### Static configuration management
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
- #### Rich Java/C#-like enums
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`
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveModule
4
+ class Railtie < Rails::Railtie
5
+ initializer "my_gem.configure_rails_initialization" do
6
+ ActiveModule::Register.call
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveModule
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
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.0
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-16 00:00:00.000000000 Z
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: Module type for ActiveModel and Active Record
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: Module type for ActiveModel and Active Record
90
+ summary: ActiveModel/ActiveRecord module attribute type implementation
90
91
  test_files: []