Sha256: d3195439313b296b0fdc89be113306cd0d80598937cfcb497b4e583d24ce653e
Contents?: true
Size: 806 Bytes
Versions: 1
Compression:
Stored size: 806 Bytes
Contents
require 'hashie/mash' # @private class Hashie::Mash # Modified Hashie::Mash method missing def method_missing(method_name, *args, &blk) begin method_name = genability_method_name_converter(method_name) rescue; end return self.[](method_name, &blk) if key?(method_name) match = method_name.to_s.match(/(.*?)([?=!]?)$/) case match[2] when "=" self[match[1]] = args.first when "?" !!self[match[1]] when "!" initializing_reader(match[1]) else default(method_name, *args, &blk) end end # Convert camelcase methods begining with a lowercase letter # into underscored methods def genability_method_name_converter(method_name) method_name.to_s.gsub(/(?:^|_)(.)/){ $1.upcase }.gsub(/^[A-Z]/){ $&.downcase }.to_sym end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
genability-0.1.0 | lib/mashie_extensions.rb |