t12n 0.1.0 → 0.2.1

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: b54eade3c7dce7e99472e6f50ea5f8949f1949baa68245dd2b1d6edb105e495a
4
- data.tar.gz: 1b54e1c8f04c6f178763b14c4c87fa86ee0671c5fb01cb4dc4b4878991825508
3
+ metadata.gz: ef2dec0bbe62bca0a96adb8dbbbcb8f34247685e1732c6da2c12b2f60a2b3ac2
4
+ data.tar.gz: c97270db164e850355428fd019c80b9f6c3343509544e0203b47aa28cbd9903c
5
5
  SHA512:
6
- metadata.gz: 84475f6188442fd3809b3fe6c9a0710fb635018dc287ea2514568e261664080c22dc3352876864497e8b24589e439a257fc2a817eafb42b80cb3cda116d92640
7
- data.tar.gz: c833f49c6487a8a3073437e01822edc502ec5e6098dcb4d3172557f4d4eb4bc27369ca5d40c4442a1b6514eb60e3710a480af350cf77edae9d45ad353a0a3b54
6
+ metadata.gz: 0501cb657af60da6ef6a3cf217fa5c3e206664eb4f5e5346f5c34c2c2054849d105ddb7127ca16e14a3c45b52b5b212540fd59112f4b78ce021b3d2f08a197c1
7
+ data.tar.gz: e557b6371029d851dcb9f9eff37617706abcb8fe395a66bc759fd4671764e825bd711a6150f8e826b373d9c46497a7646cd69edb89ce5fefcfb9095f9c9571b6
data/lib/t12n.rb CHANGED
@@ -15,7 +15,8 @@ module T12n
15
15
 
16
16
  extend self
17
17
 
18
- def start
19
- Interface.new(SchemaStore.new)
18
+ def start(schema_store: nil)
19
+ schema_store ||= SchemaStore.new
20
+ Interface.new(schema_store)
20
21
  end
21
22
  end
@@ -37,7 +37,8 @@ module T12n
37
37
 
38
38
  with_context do |context|
39
39
  schema = t12n.fetch_schema(schema_name, context)
40
- assoc_attrs = schema.attrs.select { |attr| attr_name_set.include?(attr.name) } if attr_name_set
40
+ assoc_attrs = schema.attrs
41
+ assoc_attrs = assoc_attrs.select { |attr| attr_name_set.include?(attr.name) } if attr_name_set
41
42
 
42
43
  assoc_attrs.each do |assoc_attr|
43
44
  define_attr("#{schema_name}.#{assoc_attr.name}") do |object|
@@ -8,6 +8,7 @@ module T12n
8
8
 
9
9
  def save(schema)
10
10
  schema_by_name[schema.name] = schema
11
+ :ok
11
12
  end
12
13
 
13
14
  def fetch(name)
@@ -4,7 +4,14 @@ module T12n
4
4
  class Serializer
5
5
  class << self
6
6
  def from_proc(prc)
7
- prc
7
+ case prc.arity
8
+ when 0
9
+ ->(_object) { prc.() }
10
+ when 1, -1
11
+ ->(object) { prc.(object) }
12
+ else
13
+ raise T12n::ArgumentError, "Unexpected proc arity: #{prc.arity}"
14
+ end
8
15
  end
9
16
  end
10
17
  end
data/lib/t12n/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module T12n
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: t12n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Schneider