Sha256: aff3b6b8a82549597ffb3280202248b365f7f8710aa0f62a8740b56c0e07c705
Contents?: true
Size: 850 Bytes
Versions: 15
Compression:
Stored size: 850 Bytes
Contents
module Pickle module Session # add ability to parse model names as fields, using a session module Parser def self.included(parser_class) parser_class.alias_method_chain :parse_field, :model end attr_accessor :session def match_field "(?:\\w+: (?:#{match_model}|#{match_value}))" end def parse_field_with_model(field) if session && field =~ /^(\w+): #{capture_model}$/ {$1 => session.model!($2)} else parse_field_without_model(field) end end def parse_hash(hash) hash.inject({}) do |parsed, (key, val)| if session && val =~ /^#{capture_model}$/ parsed.merge(key => session.model($1)) else parsed.merge(key => val) end end end end end end
Version data entries
15 entries across 15 versions & 3 rubygems