Class: Lurker::Json::Parser::PlainStrategy
- Inherits:
-
Object
- Object
- Lurker::Json::Parser::PlainStrategy
- Includes:
- Expertise
- Defined in:
- lib/lurker/json/parser/plain_strategy.rb
Instance Attribute Summary collapse
-
#schema_options ⇒ Object
readonly
Returns the value of attribute schema_options.
Instance Method Summary collapse
-
#initialize(options) ⇒ PlainStrategy
constructor
A new instance of PlainStrategy.
- #parse(payload) ⇒ Object
Methods included from Expertise
type_defined?, type_polymorph?, type_supposed?
Constructor Details
#initialize(options) ⇒ PlainStrategy
Returns a new instance of PlainStrategy.
9 10 11 |
# File 'lib/lurker/json/parser/plain_strategy.rb', line 9 def initialize() @schema_options = .dup end |
Instance Attribute Details
#schema_options ⇒ Object (readonly)
Returns the value of attribute schema_options.
7 8 9 |
# File 'lib/lurker/json/parser/plain_strategy.rb', line 7 def @schema_options end |
Instance Method Details
#parse(payload) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lurker/json/parser/plain_strategy.rb', line 13 def parse(payload) case payload when Lurker::Json::Schema payload when Hash return parse_as_typed(payload) if type_defined?(payload) || type_supposed?(payload) Lurker::Json::Schema.new(payload, ) when Array payload.map do |schema| Lurker::Json::Parser.plain().parse(schema) end else payload end end |