easy_struct 0.0.0
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.
- checksums.yaml +7 -0
- data/lib/easy_struct.rb +14 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: edf373ed2638c2a2beb442d3f339dcc40cfb62c9
|
4
|
+
data.tar.gz: 2c029ce58b3b7d7971ddfd9d1e05ba97749b7b58
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3f61e7af0ea65a7e4a9f331e4d67959ff55ac4c7b4950d79c961a04661742e79ce50f2dcb8ef89c5e77f17f6e07f0e563dd163796589688c28bd5f4892a96b04
|
7
|
+
data.tar.gz: 2f1595db4d1212390d558776077abba6980e8986fc322dc951196c10556948c83a6eb7329291a1b9d88a2f56ba6f6bd543b92e875770a11da279d64dde132041
|
data/lib/easy_struct.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
# A small hack written by David Roy to make OpenStruct not care about calling
|
3
|
+
# a object via snake_case when it is camelCase
|
4
|
+
class EasyStruct < OpenStruct
|
5
|
+
def method_missing(method, *args, &blk)
|
6
|
+
(/(?<name>.+?)(?<setter>=)?$/ =~ method.to_s)
|
7
|
+
property = name.camelcase(:lower).to_sym
|
8
|
+
if @table.has_key?(property)
|
9
|
+
setter ? @table[property] = args.first : @table[property]
|
10
|
+
else
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: easy_struct
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Roy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A easy way to avoid working to hard with json parsed by OpenStruct.
|
14
|
+
email: david.roy@cabbit.co.uk
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/easy_struct.rb
|
20
|
+
homepage: ''
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.6.12
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: EasyStruct!
|
44
|
+
test_files: []
|