Class: WeaselDiesel::Params::Rule
- Inherits:
-
Object
- Object
- WeaselDiesel::Params::Rule
- Defined in:
- lib/params.rb
Overview
Params usually have a few rules used to validate requests. Rules are not usually initialized directly but instead via the service’s #params accessor.
Instance Attribute Summary collapse
-
#name ⇒ Symbol, String
readonly
Name The name of the param the rule applies to.
-
#options ⇒ Hash
readonly
Options The rule options.
Instance Method Summary collapse
-
#doc ⇒ NilClass, String
The documentation of this Rule.
-
#initialize(name, opts = {}) ⇒ Rule
constructor
A new instance of Rule.
-
#namespace ⇒ NilClass, WeaselDiesel::Params::Namespace
The namespace used if any.
-
#to_hash ⇒ Hash
Converts the rule into a hash with its name and options.
Constructor Details
#initialize(name, opts = {}) ⇒ Rule
Returns a new instance of Rule.
70 71 72 73 |
# File 'lib/params.rb', line 70 def initialize(name, opts = {}) @name = name = opts end |
Instance Attribute Details
#name ⇒ Symbol, String (readonly)
Returns name The name of the param the rule applies to.
42 43 44 |
# File 'lib/params.rb', line 42 def name @name end |
#options ⇒ Hash (readonly)
Returns options The rule options.
55 56 57 |
# File 'lib/params.rb', line 55 def end |
Instance Method Details
#doc ⇒ NilClass, String
The documentation of this Rule
api public
87 88 89 |
# File 'lib/params.rb', line 87 def doc [:doc] end |
#namespace ⇒ NilClass, WeaselDiesel::Params::Namespace
The namespace used if any
79 80 81 |
# File 'lib/params.rb', line 79 def namespace [:space_name] end |
#to_hash ⇒ Hash
Converts the rule into a hash with its name and options.
94 95 96 |
# File 'lib/params.rb', line 94 def to_hash {:name => name, :options => } end |