class Scorecard::Parameters
Attributes
options[R]
prefixes[R]
Public Class Methods
new(options, prefixes = [:gameable, :user])
click to toggle source
# File lib/scorecard/parameters.rb, line 4 def initialize(options, prefixes = [:gameable, :user]) @options, @prefixes = options.clone, prefixes end
Public Instance Methods
contract()
click to toggle source
# File lib/scorecard/parameters.rb, line 20 def contract prefixes.collect(&:to_s).each do |prefix| next unless options["#{prefix}_type"] klass = options.delete("#{prefix}_type").constantize options[prefix] = klass.find options.delete("#{prefix}_id") end options.symbolize_keys end
expand()
click to toggle source
# File lib/scorecard/parameters.rb, line 8 def expand prefixes.collect(&:to_sym).each do |prefix| next unless options[prefix] options["#{prefix}_id"] = options[prefix].id options["#{prefix}_type"] = options[prefix].class.name options.delete prefix end options.stringify_keys end