data_class_factory 0.1.0 → 1.0.0

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: 85a61ac673bb16b61d606b2a332aada35a31ae1e62d0db7140fbe88f1598d84a
4
- data.tar.gz: c0533d7643ef9eaca60995f7d35797179f55471f883fb15c943e9ef53a1d95a6
3
+ metadata.gz: 248fcc0579eee6284c5b4f87deb9b1e14bc132d164306c79b674248fff88f39e
4
+ data.tar.gz: d80f4e6b79f37c08d07a4de9ccc0041dd95c6d4adda20a3796aa18813f40db8f
5
5
  SHA512:
6
- metadata.gz: bcb368e9071a14ba6da85043a57d46897ab9ee016e9587ca674964c8a39858a6be0e476f47db94718db761efd4896e0b3db156eca1457ca6294e5b8fdb535b22
7
- data.tar.gz: 1f5ca0c39dbd680fd81b6587fce069a05f5653f6b898e806a22a7ca3831572596f1218dff47bd898994492ae447b38e8fc58dcdb134b8c73e0d8b457948c2ed9
6
+ metadata.gz: 7f5afad37080bbadea3401f205e7b67af8c4fe428bff36685f55187f7db3422f195230ebd8f3bd9bfa8ed8b396dfa2fa46c9a5332d941a789277d5c494de6e87
7
+ data.tar.gz: d841d810645c0b1dbf277eb73a1ee9bade0741dccbf347e38c4856a9d2724707d63eecb7ac8b843682544929b5ff9fae088b1284b7fe1e1c3863963fa5003f42
@@ -2,15 +2,15 @@
2
2
 
3
3
  module DataClass
4
4
  # An internal class for providing implementation of `Data.define`.
5
- class Factory
6
- # @param attribute_names [Array<Symbol>]
7
- def initialize(attribute_names)
8
- @definition = Definition.new(attribute_names)
5
+ class Definer
6
+ # @param definition [Definition]
7
+ def initialize(definition)
8
+ @definition = definition
9
9
  end
10
10
 
11
11
  # @param parent_class [Data]
12
12
  # @return [Class<Data>]
13
- def create(parent_class:, &block)
13
+ def define_class(parent_class:, &block)
14
14
  attribute_names = @definition.attribute_names
15
15
 
16
16
  # defines a subclass of Data.
@@ -8,7 +8,7 @@ module DataClass
8
8
  # @param attribute_names [Array<Symbol>]
9
9
  def initialize(attribute_names)
10
10
  validate_attribute_names(attribute_names)
11
- @attribute_names = attribute_names.each { |key| validate_attribute_name(key) }
11
+ @attribute_names = attribute_names
12
12
  end
13
13
  attr_reader :attribute_names
14
14
 
@@ -37,7 +37,5 @@ module DataClass
37
37
  checked << key
38
38
  end
39
39
  end
40
-
41
- def validate_attribute_name(key); end
42
40
  end
43
41
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DataClassFactory
4
- VERSION = '0.1.0'
4
+ VERSION = '1.0.0'
5
5
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'data_class_factory/version'
4
+ require 'data_class/definer'
4
5
  require 'data_class/definition'
5
- require 'data_class/factory'
6
6
  require 'data_class/instance_methods'
7
7
 
8
8
  # Defining a factory class.
@@ -12,8 +12,9 @@ require 'data_class/instance_methods'
12
12
  # # @param attribute_names [Array<Symbol>]
13
13
  # # @return [Class<Data>]
14
14
  # def self.define(*attribute_names, &block)
15
- # factory = DataClass::Factory.new(attribute_names)
16
- # factory.create(parent_class: self, &block)
15
+ # definition = DataClass::Definition.new(attribute_names)
16
+ # definer = DataClass::Definer.new(definition)
17
+ # definer.define_class(parent_class: self, &block)
17
18
  # end
18
19
  # ...
19
20
  # end
@@ -26,8 +27,9 @@ module DataClassFactory
26
27
  def define_factory_class
27
28
  Class.new do
28
29
  define_singleton_method(:define) do |*attribute_names, &block|
29
- factory = DataClass::Factory.new(attribute_names)
30
- factory.create(parent_class: self, &block)
30
+ definition = DataClass::Definition.new(attribute_names)
31
+ definer = DataClass::Definer.new(definition)
32
+ definer.define_class(parent_class: self, &block)
31
33
  end
32
34
  private_class_method :new
33
35
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_class_factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
@@ -109,8 +109,8 @@ files:
109
109
  - bin/setup
110
110
  - data_class_factory.gemspec
111
111
  - lib/data.rb
112
+ - lib/data_class/definer.rb
112
113
  - lib/data_class/definition.rb
113
- - lib/data_class/factory.rb
114
114
  - lib/data_class/instance_methods.rb
115
115
  - lib/data_class_factory.rb
116
116
  - lib/data_class_factory/version.rb