fast_struct 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fast_struct.rb +41 -0
- metadata +67 -0
data/lib/fast_struct.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
class FastStruct
|
2
|
+
def initialize hash={}
|
3
|
+
@hash = {}
|
4
|
+
hash.each do |_k, v|
|
5
|
+
set(_k, v)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing _k, v=nil
|
10
|
+
return @hash[_k]
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_hash
|
14
|
+
@hash
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_h
|
18
|
+
to_hash
|
19
|
+
end
|
20
|
+
|
21
|
+
def [](k)
|
22
|
+
self.send(k)
|
23
|
+
end
|
24
|
+
|
25
|
+
def []=(k, v)
|
26
|
+
set(k, v)
|
27
|
+
end
|
28
|
+
|
29
|
+
def set(_k, v)
|
30
|
+
k = _k.is_a?(Symbol) ? _k : _k.intern
|
31
|
+
if v.is_a? Hash
|
32
|
+
v = FastStruct.new(v)
|
33
|
+
end
|
34
|
+
@hash[k] = v
|
35
|
+
v
|
36
|
+
end
|
37
|
+
|
38
|
+
def delete_field k
|
39
|
+
@hash.delete k
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fast_struct
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Aditya Bhargava
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2013-02-26 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: A very fast implementation of OpenStruct that also supports deep wrapping.
|
23
|
+
email: bluemangroupie@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- lib/fast_struct.rb
|
32
|
+
has_rdoc: true
|
33
|
+
homepage: https://www.github.com/egonSchiele/fast_struct
|
34
|
+
licenses: []
|
35
|
+
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 3
|
47
|
+
segments:
|
48
|
+
- 0
|
49
|
+
version: "0"
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
hash: 3
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
requirements: []
|
60
|
+
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 1.3.7
|
63
|
+
signing_key:
|
64
|
+
specification_version: 3
|
65
|
+
summary: A very fast implementation of OpenStruct that also supports deep wrapping.
|
66
|
+
test_files: []
|
67
|
+
|