Sha256: c4e9b20ee864364a097a8a3162a28af7b2d4152cbca57f787635d290310e2ceb
Contents?: true
Size: 670 Bytes
Versions: 5
Compression:
Stored size: 670 Bytes
Contents
require "app_store/helper" module AppStore::Helper::Plist def plist(params = {}) mapping = params[:mapping].collect do |plist_key, attr_name| # First, make attribute readable outside the instance class_eval "attr_reader :#{attr_name}" # Then, build the content of init_from_plist function "@#{attr_name} = plist['#{plist_key}']" end rescue [] class_eval <<-EOV, __FILE__, __LINE__ protected def init_from_plist(plist) #{"raise AppStore::ParseError unless plist['type'] == '#{params[:accepted_type]}'" if params[:accepted_type]} super #{mapping.join("\n")} end EOV end end
Version data entries
5 entries across 5 versions & 1 rubygems