Class: Apipie::Params::Descriptor::Base
- Inherits:
-
Object
- Object
- Apipie::Params::Descriptor::Base
- Defined in:
- lib/apipie/params/descriptor.rb
Direct Known Subclasses
Class Method Summary collapse
-
.find(argument, options, block) ⇒ Object
find the right descriptor for given options.
- .inherited(subclass) ⇒ Object
Instance Method Summary collapse
-
#description ⇒ Object
to be used in the error description and json representation.
-
#initialize(options) ⇒ Base
constructor
A new instance of Base.
- #invalid_param_error(param_description, error_value, errors = []) ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(options) ⇒ Base
Returns a new instance of Base.
9 10 11 12 13 14 15 |
# File 'lib/apipie/params/descriptor.rb', line 9 def initialize() if .is_a? ::Hash @options = else @options = {} end end |
Class Method Details
.find(argument, options, block) ⇒ Object
find the right descriptor for given options
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/apipie/params/descriptor.rb', line 23 def self.find(argument, , block) if argument.is_a? Descriptor::Base return argument end # in case param description (or something else quacking the # same) is passed if argument.respond_to?(:descriptor) && argument.descriptor.is_a?(Descriptor::Base) return argument.descriptor end @descriptor_classes.each do |descriptor_class| descriptor = descriptor_class.build(argument, , block) return descriptor if descriptor end return nil end |
.inherited(subclass) ⇒ Object
17 18 19 20 |
# File 'lib/apipie/params/descriptor.rb', line 17 def self.inherited(subclass) @descriptor_classes ||= [] @descriptor_classes.insert 0, subclass end |
Instance Method Details
#description ⇒ Object
to be used in the error description and json representation
44 45 46 |
# File 'lib/apipie/params/descriptor.rb', line 44 def description "" end |
#invalid_param_error(param_description, error_value, errors = []) ⇒ Object
48 49 50 |
# File 'lib/apipie/params/descriptor.rb', line 48 def invalid_param_error(param_description, error_value, errors = []) Params::Errors::Invalid.new(param_description, error_value, description) end |
#to_json ⇒ Object
52 53 54 |
# File 'lib/apipie/params/descriptor.rb', line 52 def to_json self.json_schema end |