Class: Scorecard::Parameters
- Inherits:
-
Object
- Object
- Scorecard::Parameters
- Defined in:
- lib/scorecard/parameters.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#prefixes ⇒ Object
readonly
Returns the value of attribute prefixes.
Instance Method Summary collapse
- #contract ⇒ Object
- #expand ⇒ Object
-
#initialize(options, prefixes = [:gameable, :user]) ⇒ Parameters
constructor
A new instance of Parameters.
Constructor Details
#initialize(options, prefixes = [:gameable, :user]) ⇒ Parameters
Returns a new instance of Parameters.
4 5 6 |
# File 'lib/scorecard/parameters.rb', line 4 def initialize(, prefixes = [:gameable, :user]) @options, @prefixes = .clone, prefixes end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
2 3 4 |
# File 'lib/scorecard/parameters.rb', line 2 def @options end |
#prefixes ⇒ Object (readonly)
Returns the value of attribute prefixes.
2 3 4 |
# File 'lib/scorecard/parameters.rb', line 2 def prefixes @prefixes end |
Instance Method Details
#contract ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/scorecard/parameters.rb', line 20 def contract prefixes.collect(&:to_s).each do |prefix| next unless ["#{prefix}_type"] klass = .delete("#{prefix}_type").constantize [prefix] = klass.find .delete("#{prefix}_id") end .symbolize_keys end |
#expand ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/scorecard/parameters.rb', line 8 def prefixes.collect(&:to_sym).each do |prefix| next unless [prefix] ["#{prefix}_id"] = [prefix].id ["#{prefix}_type"] = [prefix].class.name .delete prefix end .stringify_keys end |