Sha256: f7526e48087cabbf6cdd37f1bd207fff4b84f13c087266f3df42af1fe13b022a
Contents?: true
Size: 534 Bytes
Versions: 3
Compression:
Stored size: 534 Bytes
Contents
module Petfinder module JsonMapper def json_attributes(*names) names.each { |name| json_attribute(name) } end def json_attribute name define_method name do if name.include? "_" camelName = name.split("_").map { |word| word.capitalize unless word == (name.split("_").first) }.join @attributes.dig(camelName, "$t") elsif @attributes.dig(name, "$t") @attributes.dig(name, "$t") else @attributes["#{name}"] end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
petfinder-wrap-1.0.2 | lib/petfinder/json-mapper.rb |
petfinder-wrap-1.0.1.1 | lib/petfinder/json-mapper.rb |
petfinder-wrap-1.0.0 | lib/petfinder/json-mapper.rb |