schema-model 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46f7554a43ea84d40fc6befa498bfa66bd3362c7673da1c5e9719926c6fecb6b
4
- data.tar.gz: dbaa36dea474d468145a91996c1b817e3ce7fd23132cf4feeadb0ab80500566d
3
+ metadata.gz: b72fb0e41743e3c662c33b14ab05ac593d638f7b13815f59a61f911ecedd96fb
4
+ data.tar.gz: 5240afec97492c8a362acbc8de0e1257e2cbdac1251db48e22cb5a33b6ec855d
5
5
  SHA512:
6
- metadata.gz: bd488a8d9a99d9f33c20c5f1662a85b1a2eb869a9b2703125065fc7b84b9c92911b4d6b604534255c485a19926aab42aa4da3153a03de97c4b3aeceed655e922
7
- data.tar.gz: 5cb585cae9631cae66e3f390b4e1d34e41e405c6d8481c814f032d53203b9437048bdc78946c7164ac55531e06d4231e7d638ca814642471e2d18096f9138fc2
6
+ metadata.gz: 99de0c37026fad9c8d976d47d75af0c65fc39c4b527503398227084e4d582c53a213ea12d8b782483bf7d0242f370bdec19bbad676031faf1b49e5e0a35952b1
7
+ data.tar.gz: 6e3f5ece082047b713af401875d2004c422d777605c89ccd0e69ae01fa0ce9a341f222f1f8ba37cd4b158cd0ff28a1c4bfa0648ccc040a8ad13adb8e93197b68
@@ -47,7 +47,7 @@ module Schema
47
47
  mapped_model = mapped_headers[field_name] || {}
48
48
  const_get(field_options[:class_name]).get_field_names(
49
49
  mapped_model,
50
- header_prefix || field_options[:aliases]&.first,
50
+ header_prefix || (field_options[:aliases] && field_options[:aliases].first),
51
51
  mapped
52
52
  )
53
53
  end
@@ -15,19 +15,19 @@ module Schema
15
15
  options = ::Schema::Utils.add_association_class(self, name, :has_many, options)
16
16
 
17
17
  class_eval(
18
- <<~STR, __FILE__, __LINE__ + 1
19
- def #{options[:getter]}
20
- #{options[:instance_variable]}
21
- end
18
+ <<~STR
19
+ def #{options[:getter]}
20
+ #{options[:instance_variable]}
21
+ end
22
22
 
23
- def #{name}_schema_creator
24
- @#{name}_schema_creator ||= ::Schema::Associations::SchemaCreator.new(self, #{name.inspect})
25
- end
23
+ def #{name}_schema_creator
24
+ @#{name}_schema_creator ||= ::Schema::Associations::SchemaCreator.new(self, #{name.inspect})
25
+ end
26
26
 
27
- def #{options[:setter]}(v)
28
- #{options[:instance_variable]} = #{name}_schema_creator.create_schemas(self, v)
29
- end
30
- STR
27
+ def #{options[:setter]}(v)
28
+ #{options[:instance_variable]} = #{name}_schema_creator.create_schemas(self, v)
29
+ end
30
+ STR
31
31
  )
32
32
 
33
33
  kls = const_get(options[:class_name])
@@ -15,19 +15,19 @@ module Schema
15
15
  options = ::Schema::Utils.add_association_class(self, name, :has_one, options)
16
16
 
17
17
  class_eval(
18
- <<~STR, __FILE__, __LINE__ + 1
19
- def #{options[:getter]}
20
- #{options[:instance_variable]}
21
- end
18
+ <<~STR
19
+ def #{options[:getter]}
20
+ #{options[:instance_variable]}
21
+ end
22
22
 
23
- def #{name}_schema_creator
24
- @#{name}_schema_creator ||= ::Schema::Associations::SchemaCreator.new(self, #{name.inspect})
25
- end
23
+ def #{name}_schema_creator
24
+ @#{name}_schema_creator ||= ::Schema::Associations::SchemaCreator.new(self, #{name.inspect})
25
+ end
26
26
 
27
- def #{options[:setter]}(v)
28
- #{options[:instance_variable]} = #{name}_schema_creator.create_schema(self, v)
29
- end
30
- STR
27
+ def #{options[:setter]}(v)
28
+ #{options[:instance_variable]} = #{name}_schema_creator.create_schema(self, v)
29
+ end
30
+ STR
31
31
  )
32
32
 
33
33
  kls = const_get(options[:class_name])
data/lib/schema/model.rb CHANGED
@@ -69,20 +69,22 @@ module Schema
69
69
 
70
70
  def add_attribute_methods(name, options)
71
71
  class_eval(
72
- <<~STR, __FILE__, __LINE__ + 1
73
- def #{options[:getter]}
74
- #{options[:instance_variable]}
75
- end
76
-
77
- def #{options[:setter]}(v)
78
- #{options[:instance_variable]} = #{options[:parser]}(#{name.inspect}, parsing_errors, v)
79
- end
80
- STR
72
+ <<~STR
73
+ def #{options[:getter]}
74
+ #{options[:instance_variable]}
75
+ end
76
+
77
+ def #{options[:setter]}(v)
78
+ #{options[:instance_variable]} = #{options[:parser]}(#{name.inspect}, parsing_errors, v)
79
+ end
80
+ STR
81
81
  )
82
82
  end
83
83
 
84
84
  def add_aliases(name, options)
85
- options[:aliases]&.each do |alias_name|
85
+ return unless options[:aliases]
86
+
87
+ options[:aliases].each do |alias_name|
86
88
  add_value_to_class_method(:schema, alias_name.to_sym => options.merge(key: alias_name.to_s, alias_of: name))
87
89
  alias_method(alias_name, options[:getter])
88
90
  alias_method("#{alias_name}=", options[:setter])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Doug Youch