active_act 0.1.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f97bab53c823e61bd0c317974fab745a3a0a7d5f056ca6dd992cf5d4566f741f
4
- data.tar.gz: 6fafffba84d21351f1a5db402986bb0675c269128c65ae4058cac08dcf54d848
3
+ metadata.gz: d32b4fc44895ec6ae4d8f5826dfd8c99e689b60b157cc223540a30999ef2b0bc
4
+ data.tar.gz: b520dca1c499360f853c86e3c1e2bc68c7ba22193016cd4d5ea6ad107390eab6
5
5
  SHA512:
6
- metadata.gz: 7bf8afdad1c966dd28fc0a1468cb733e903368781736fbdd858944eb9a5136324a0cc016fcedf5e521533e255ecb904b30f78cee6264faa9d3a84697661f2837
7
- data.tar.gz: ef9578a447f242e263d2bb69dec9355ee7965d6bd46d4a41d2d80178233d0785531a0fb97f47f4b0960514f60b2e00c3b2d35a693575a33a800535c67559677b
6
+ metadata.gz: e1d2fd0bbe132ed7ac4cd9ea68a17cf4f03c4cde6fb1a45717c7a238624ff8fe86aa7b11a02852fe74009ea6ab3c50399c64d380ff8811a4de4a26855bb87642
7
+ data.tar.gz: 66feb2659095671305ff2939fb36c4b52c8adbf2966f7b4a05a9beb7b52ac4a819f1ebec8922b4b603333f546a9f033b1ca6d0cd2ec78bbde4fe6fe941e55ecf
data/README.md CHANGED
@@ -16,23 +16,23 @@ And then execute:
16
16
  $ bundle install
17
17
  ```
18
18
 
19
- Run the install generator to set up the base structure:
19
+ Run the install generator to set up the actions directory:
20
20
 
21
21
  ```sh
22
22
  $ rails generate active_act:install
23
23
  ```
24
24
 
25
- This will create the `app/actions` directory and a base `application_action.rb` file.
25
+ This will create the `app/actions` directory. The base class `ActiveAct::ApplicationAction` is provided by the gem and does not need to be generated in your app.
26
26
 
27
27
  ## Usage
28
28
 
29
29
  ### Creating a new Action
30
30
 
31
- You can manually create a new action by inheriting from `ApplicationAction`:
31
+ Create a new action by inheriting from `ActiveAct::ApplicationAction`:
32
32
 
33
33
  ```ruby
34
34
  # app/actions/send_welcome_email.rb
35
- class SendWelcomeEmail < ApplicationAction
35
+ class SendWelcomeEmail < ActiveAct::ApplicationAction
36
36
  def initialize(user)
37
37
  @user = user
38
38
  end
@@ -46,12 +46,6 @@ class SendWelcomeEmail < ApplicationAction
46
46
  end
47
47
  ```
48
48
 
49
- Or, use the (upcoming) generator:
50
-
51
- ```sh
52
- $ rails generate active_act:action SendWelcomeEmail
53
- ```
54
-
55
49
  ### Executing an Action
56
50
 
57
51
  You can call your action from anywhere in your app:
@@ -62,7 +56,7 @@ SendWelcomeEmail.call(user)
62
56
 
63
57
  ## Base Action API
64
58
 
65
- The generated `ApplicationAction` provides:
59
+ The provided `ActiveAct::ApplicationAction` includes:
66
60
 
67
61
  - `.call(*args, **kwargs, &block)`: Instantiates and runs the action.
68
62
  - `#call`: To be implemented in your subclass.
@@ -72,7 +66,7 @@ The generated `ApplicationAction` provides:
72
66
 
73
67
  ```ruby
74
68
  # app/actions/process_payment.rb
75
- class ProcessPayment < ApplicationAction
69
+ class ProcessPayment < ActiveAct::ApplicationAction
76
70
  def initialize(order)
77
71
  @order = order
78
72
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveAct
4
+ class ApplicationAction
5
+ def self.call(*args, **kwargs, &block)
6
+ new(*args, **kwargs, &block).call
7
+ end
8
+
9
+ def call
10
+ raise NotImplementedError, "You must implement the #call method in your action."
11
+ end
12
+
13
+ def fail(error = nil)
14
+ raise(error || "Action failed")
15
+ end
16
+ end
17
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveAct
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -7,15 +7,11 @@ module ActiveAct
7
7
  class InstallGenerator < Rails::Generators::Base
8
8
  source_root File.expand_path("templates", __dir__)
9
9
 
10
- desc "Creates the app/actions structure and the base application_action.rb file."
10
+ desc "Creates the app/actions structure."
11
11
 
12
12
  def create_actions_directory
13
13
  empty_directory "app/actions"
14
14
  end
15
-
16
- def copy_application_action
17
- template "application_action.rb", "app/actions/application_action.rb"
18
- end
19
15
  end
20
16
  end
21
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_act
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magdiel Cardoso
@@ -24,9 +24,9 @@ files:
24
24
  - LICENSE.txt
25
25
  - README.md
26
26
  - Rakefile
27
- - active_act-0.1.0.gem
28
27
  - app/actions/application_action.rb
29
28
  - lib/active_act.rb
29
+ - lib/active_act/application_action.rb
30
30
  - lib/active_act/engine.rb
31
31
  - lib/active_act/version.rb
32
32
  - lib/generators/active_act/install/install_generator.rb
data/active_act-0.1.0.gem DELETED
Binary file