mores 0.1.4 → 0.1.5

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
  SHA1:
3
- metadata.gz: 3c825f049765d83153bea198a9c80472ded666b2
4
- data.tar.gz: bf64d654bb527c103d9ef26d1283a8724231acc6
3
+ metadata.gz: 6a05f6aa6035150e1284633d30bbb3a0da3a96b5
4
+ data.tar.gz: f04a463e4896ee94728c23f6441459bd170243a6
5
5
  SHA512:
6
- metadata.gz: 81c6a14bb8284528ccf33ba80cebe8bf4c7c35a496a63f79f30b7937b5009caa90dd0bdf3a782e24533f6195ac70ada06bc3a890da4693e8b51b64b400fa2cd2
7
- data.tar.gz: 3037ddb8b32afbc6be8978930d3ea40155a3399f8a9046e0d6eb1ac7d18e1711c8a671086ebc5aabde2e80eacb7ee8baf8eeb6d4dff0bd8dec085c30cf8af9b5
6
+ metadata.gz: 3203d0ab814d35b943ebabeb7c76daac713c60f2fbf73420490655651a9bff54f561c9bcdb627d013996112aef99bd5635ecd963b709eecbe9f7ae2408add332
7
+ data.tar.gz: 947196ce46eabf9689decec1861f17fa54da0898b07fcec35d29cfa0bf302e2d0655c416e4634d337ac97202f5bc2515d7f7fa8d6f199ad75ddc263a22013893
data/lib/mores.rb CHANGED
@@ -2,3 +2,4 @@ require 'mores/version'
2
2
  require 'mores/block_initialize'
3
3
  require 'mores/linked_list'
4
4
  require 'mores/succession'
5
+ require 'mores/immutable_struct'
@@ -0,0 +1,24 @@
1
+ module Mores
2
+
3
+ class ImmutableStruct < ::Struct
4
+ require_relative 'immutable_struct/flyweight'
5
+ require_relative 'immutable_struct/strict'
6
+
7
+ DEFAULT_OPTIONS = { flyweight: true }.freeze
8
+
9
+ undef_method :[]=
10
+
11
+ def self.new(*args, **options, &block)
12
+ options = DEFAULT_OPTIONS.merge options
13
+
14
+ super(*args, &block).tap do |klass|
15
+ klass.instance_eval do
16
+ members.each { |x| remove_method "#{x}=" }
17
+ include Flyweight if options[:flyweight]
18
+ include Strict if options[:strict]
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,5 @@
1
+ module Mores::ImmutableStruct::Flyweight
2
+ def clone
3
+ self
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ module Mores::ImmutableStruct::Strict
2
+ def initialize(*args)
3
+ unless args.count == members.count
4
+ raise ArgumentError, "wrong number of arguments (#{args.count} for #{members.count})"
5
+ end
6
+ super
7
+ end
8
+ end
data/lib/mores/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mores
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mores
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Petter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-13 00:00:00.000000000 Z
11
+ date: 2016-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,6 +78,9 @@ files:
78
78
  - README.md
79
79
  - lib/mores.rb
80
80
  - lib/mores/block_initialize.rb
81
+ - lib/mores/immutable_struct.rb
82
+ - lib/mores/immutable_struct/flyweight.rb
83
+ - lib/mores/immutable_struct/strict.rb
81
84
  - lib/mores/linked_list.rb
82
85
  - lib/mores/succession.rb
83
86
  - lib/mores/version.rb