Class: ActionController::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/types/rails/action_controller/strong_parameters.rb,
lib/rdl/boot_rails.rb

Overview

TODO: This is all a bit of a hack. Right now, ActionControll::Parameters has its [] method set appropriately during the context of the next method by params_types. But that doesn’t quite match what actually happens in Rails.

Class Method Summary collapse

Class Method Details

.params_type(typs) ⇒ Object

+ typ_hash +

is a Hash<Symbol, String>, where the keys are the parameter names and the Strings are the corresponding types

adds these parameters to the params hash in the immediately following controller method



8
9
10
11
12
13
14
15
# File 'lib/types/rails/action_controller/strong_parameters.rb', line 8

def self.params_type(typs)
  # TODO: Ick, this is ugly. Once it's obvious how to generalize this kind of reasoning to other cases, clean this up!
  typs.each_pair { |param, param_type|
    param_type = RDL::Globals.parser.scan_str "#T #{param_type}"
    meth_type = RDL::Globals.parser.scan_str "(#{param.inspect}) -> #{param_type}" # given singleton symbol arg, get param's return type
    RDL::Globals.deferred << [self, :context_types, [ActionController::Parameters, :[], meth_type], class_check: self]
  }
end