formify 0.12.2 → 0.13.3

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: 050e832ec02defe8b5fa78fd7c695cadc17820492f73c64963569d363903c3ed
4
- data.tar.gz: 560ad4c14628e080876a9bfc1ff3c84888f447246e442361b66fa0501d888af6
3
+ metadata.gz: fe71eec837e180dbca7f7d146817af141983654b51408a8103252f02edae847e
4
+ data.tar.gz: 1386c4cb5e00795591b516cb2e8ec95ec6c8db76c7a8646294db82848889beb5
5
5
  SHA512:
6
- metadata.gz: 73c2cf4d790ee528f0b3547427e7962bcb21aa1336e6ce8b63d7f7170d4c1a09256303ea19e6454bfad628eb3078f772cc8447c05bd216371c48cf33857a4d48
7
- data.tar.gz: 21d39ed280dd597b7cceb186583a238b560d2332235678243950c75780f4c945905787e8059660add17bd89ef0d2e4f5195e4d3c94bc4df5c41c4944f1954bf6
6
+ metadata.gz: 2c0cd5c592eddee0658f0fcb99b91a5d77aeda7cc179cfec3289c6325571d1b640c5b964afc96d3016c8d9e0fa4aefc8b5fde731db510ffe452abb9945b96d0d
7
+ data.tar.gz: aca56e783c4ee7382150797edf831161ba874df1ad5913747329526dae572d26956422cbb4a2c4d039a1b0cf8d3cb14a62630752b14131c93e519ef87f72e7c1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- formify (0.12.2)
4
+ formify (0.13.3)
5
5
  resonad
6
6
 
7
7
  GEM
data/lib/formify/form.rb CHANGED
@@ -4,6 +4,24 @@ module Formify
4
4
  module Form
5
5
  extend ActiveSupport::Concern
6
6
 
7
+ module ClassMethods
8
+ def initialize_with(*args, &block)
9
+ define_method(:initialize) do |attributes = {}|
10
+ args.each do |arg|
11
+ instance_variable_set("@#{arg}", attributes[arg])
12
+ end
13
+
14
+ instance_exec(attributes, &block) if block_given?
15
+
16
+ super(attributes)
17
+ end
18
+ end
19
+ end
20
+
21
+ def self.included(base)
22
+ base.extend ClassMethods
23
+ end
24
+
7
25
  included do
8
26
  include ActiveModel::Model
9
27
  define_model_callbacks :save
@@ -11,7 +29,6 @@ module Formify
11
29
  include ActiveModel::Validations
12
30
  include ActiveModel::Validations::Callbacks
13
31
 
14
-
15
32
  def failure(*args)
16
33
  Resonad.Failure(*args)
17
34
  end
@@ -1,3 +1,3 @@
1
1
  module Formify
2
- VERSION = '0.12.2'.freeze
2
+ VERSION = '0.13.3'.freeze
3
3
  end
@@ -4,7 +4,7 @@
4
4
  class <%= name.split('/').last.to_s.camelcase %>
5
5
  include Formify::Form
6
6
 
7
- # attr_accessor :foo
7
+ # attr_accessor :fixed_attr
8
8
 
9
9
  # delegate_accessor :bar
10
10
  # :baz,
@@ -16,11 +16,8 @@ class <%= name.split('/').last.to_s.camelcase %>
16
16
 
17
17
  # validate :validate_
18
18
 
19
- # def initialize(attributes = {})
20
- # raise NotImplementedError
21
- #
22
- # self.fixed_attr = attributes[:fixed_attr]
23
- # super(attributes)
19
+ # initialize_with :fixed_attr do |attributes|
20
+ # puts attributes
24
21
  # end
25
22
 
26
23
  def save
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.2
4
+ version: 0.13.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Jackson