class2 0.2.3 → 0.2.4

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
  SHA1:
3
- metadata.gz: 0646247304bc24095f0581f97b1bd1ca81638afd
4
- data.tar.gz: af1db39469174d56a2da022c08f1bd00cb0d171b
3
+ metadata.gz: d28278c666d335e00c402bfe8a9fee27401b5a53
4
+ data.tar.gz: 3a9b9f915aef1ec7c1e667683e13d38012260014
5
5
  SHA512:
6
- metadata.gz: b36794076c8fbdc3103417ef80168931bd03bfd671d64168c6add76aded76f445a75b2a73f4df8bc8c4d224926379bdb8cb74cfa3170b105d93bbc7f4f7544ea
7
- data.tar.gz: 89269198476ad0561b081f0d93afabb5738a96981cb3618d6e52dca704927be9a6359afb64a210d14bd4e00f46ee123dfea7decae00041621d4f1735512c02b1
6
+ metadata.gz: ea280987e3fdf000a2c2e649170a9d83843e79628e3ed5b6ac8544176698c618d8f5c99cb64c23e51af4efe44a756194d292990aefc8b48caf2b552d7f4543b3
7
+ data.tar.gz: 6750ec3c675d3389b2e0be76e5d5891e587bed45fe97677a12b1c6fa4eadcfb0b81f0ccd08f104eebc92740775dedb3d48d91a441fa869ee2bdddc67e9c3c5cc
data/Changes CHANGED
@@ -1,3 +1,8 @@
1
+ 2017-10-22 v0.2.4
2
+ --------------------
3
+ * Add class2 filename and linenum to generated classes
4
+ * Bug fix: use the correct class name when instantiating a default nested instance
5
+
1
6
  2017-10-11 v0.2.3
2
7
  --------------------
3
8
  * Bug fix: don't try to convert to Float, Fixnum, Date, DateTime when nil
@@ -106,18 +106,18 @@ class Class2
106
106
  object.each { |klass, attrs| make_class(namespace, klass, attrs, block) }
107
107
  end
108
108
 
109
- make_method_name = lambda { |x| x.to_s.gsub(/[^\w]+/, "_") } # good enough
110
-
111
109
  name = name.to_s.classify
112
110
  return if namespace.const_defined?(name)
113
111
 
112
+ make_method_name = lambda { |x| x.to_s.gsub(/[^\w]+/, "_") } # good enough
113
+
114
114
  klass = Class.new do
115
115
  def initialize(attributes = nil)
116
116
  return unless attributes.is_a?(Hash)
117
117
  assign_attributes(attributes)
118
118
  end
119
119
 
120
- class_eval <<-CODE
120
+ class_eval <<-CODE, __FILE__, __LINE__
121
121
  def hash
122
122
  to_h.hash
123
123
  end
@@ -178,7 +178,7 @@ class Class2
178
178
  "nil"
179
179
  end
180
180
 
181
- class_eval <<-CODE
181
+ class_eval <<-CODE, __FILE__, __LINE__
182
182
  def #{method}
183
183
  @#{method} = #{retval} unless defined? @#{method}
184
184
  @#{method}
@@ -194,7 +194,7 @@ class Class2
194
194
  method = make_method_name[method]
195
195
  attr_writer method
196
196
 
197
- retval = method == method.pluralize ? "[]" : "#{method.classify}.new"
197
+ retval = method == method.pluralize ? "[]" : "#{namespace}::#{method.classify}.new"
198
198
  class_eval <<-CODE
199
199
  def #{method}
200
200
  @#{method} ||= #{retval}
@@ -1,3 +1,3 @@
1
1
  class Class2
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: class2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Skye Shaw
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-12 00:00:00.000000000 Z
11
+ date: 2017-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport