funkr 0.0.16 → 0.0.17

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.
@@ -0,0 +1,32 @@
1
+ module Funkr
2
+ module Types
3
+
4
+ class SimpleRecord < Array
5
+ ### usage : r = SimpleRecord.new(Hash), then r.field
6
+ ### r = SimpleRecord.new( name: "Paul", age: 27 )
7
+ ### r.name => "Paul" ; r.age => 27
8
+ ### name, age = r
9
+
10
+ def initialize(key_vals)
11
+ @key_vals = key_vals
12
+ key_vals.each do |k,v|
13
+ getter = k.to_sym
14
+ setter = format("%s=", k.to_s).to_sym
15
+ define_singleton_method(getter){ @key_vals[k] }
16
+ define_singleton_method(setter){|nv| @key_vals[k] = nv}
17
+ self.push(v)
18
+ end
19
+ end
20
+
21
+ def with(new_key_vals)
22
+ self.class.new(@key_vals.merge(new_key_vals))
23
+ end
24
+
25
+ def to_hash; @key_vals; end
26
+
27
+ def to_s; @key_vals.to_s; end
28
+
29
+ end
30
+
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module Funkr
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 16
9
- version: 0.0.16
8
+ - 17
9
+ version: 0.0.17
10
10
  platform: ruby
11
11
  authors:
12
12
  - Paul Rivier
@@ -49,6 +49,7 @@ files:
49
49
  - lib/funkr/types.rb
50
50
  - lib/funkr/types/failable.rb
51
51
  - lib/funkr/types/maybe.rb
52
+ - lib/funkr/types/simple_record.rb
52
53
  - lib/funkr/version.rb
53
54
  - test/tests.rb
54
55
  has_rdoc: true