class Struct
Public Class Methods
from_hash(h)
click to toggle source
# File lib/libis/tools/extend/struct.rb, line 16 def self.from_hash(h) h.symbolize_keys! members.inject(new) {|o,m| o[m] = h[m] if h.key?(m); o} end
from_json(j)
click to toggle source
# File lib/libis/tools/extend/struct.rb, line 25 def self.from_json(j) from_hash(JSON.parse(j)) end
Public Instance Methods
set(h = {})
click to toggle source
def to_hash
members.inject({}) {|h,m| h[m] = send(m); h}
end unless method_defined? :to_hash
# File lib/libis/tools/extend/struct.rb, line 10 def set(h = {}) h.symbolize_keys! members.each {|m| send("#{m}=", h[m]) if h.key?(m)} self end
to_json()
click to toggle source
# File lib/libis/tools/extend/struct.rb, line 21 def to_json to_hash.to_json end