Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0dd768
commit 914dd77
Showing
19 changed files
with
218 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ | |
end | ||
end | ||
|
||
$defs << "-DJSON_GENERATOR" | ||
create_makefile 'json/ext/generator' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'ostruct' | ||
|
||
module JSON | ||
class GenericObject < OpenStruct | ||
class << self | ||
alias [] new | ||
|
||
def json_create(data) | ||
data = data.dup | ||
data.delete JSON.create_id | ||
self[data] | ||
end | ||
end | ||
|
||
def to_hash | ||
table | ||
end | ||
|
||
def [](name) | ||
table[name.to_sym] | ||
end | ||
|
||
def []=(name, value) | ||
__send__ "#{name}=", value | ||
end | ||
|
||
def |(other) | ||
self.class[other.to_hash.merge(to_hash)] | ||
end | ||
|
||
def as_json(*) | ||
{ JSON.create_id => self.class.name }.merge to_hash | ||
end | ||
|
||
def to_json(*a) | ||
as_json.to_json(*a) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.