class2 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changes +5 -0
- data/lib/class2.rb +5 -5
- data/lib/class2/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d28278c666d335e00c402bfe8a9fee27401b5a53
|
4
|
+
data.tar.gz: 3a9b9f915aef1ec7c1e667683e13d38012260014
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/class2.rb
CHANGED
@@ -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}
|
data/lib/class2/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|