Class: WSDSL::Params::Rule
- Inherits:
-
Object
- Object
- WSDSL::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
-
#initialize(name, opts = {}) ⇒ Rule
constructor
A new instance of Rule.
-
#namespace ⇒ NilClass, String
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.
40 41 42 43 |
# File 'lib/params.rb', line 40 def initialize(name, opts = {}) @name = name @options = opts end |
Instance Attribute Details
#name ⇒ Symbol, String (readonly)
Returns name The name of the param the rule applies to.
19 20 21 |
# File 'lib/params.rb', line 19 def name @name end |
#options ⇒ Hash (readonly)
Returns options The rule options.
28 29 30 |
# File 'lib/params.rb', line 28 def @options end |
Instance Method Details
#namespace ⇒ NilClass, String
The namespace used if any
49 50 51 |
# File 'lib/params.rb', line 49 def namespace @options[:space_name] end |
#to_hash ⇒ Hash
Converts the rule into a hash with its name and options.
56 57 58 |
# File 'lib/params.rb', line 56 def to_hash {:name => name, :options => } end |