Class: RequestHandler::PageParser
- Inherits:
-
Object
- Object
- RequestHandler::PageParser
- Includes:
- Concerns::ConfigHelper
- Defined in:
- lib/request_handler/page_parser.rb
Instance Method Summary collapse
-
#initialize(params:, page_config:) ⇒ PageParser
constructor
A new instance of PageParser.
- #run ⇒ Object
Methods included from Concerns::ConfigHelper
#deep_to_h, #lookup, #lookup!, #symbolize_key
Constructor Details
#initialize(params:, page_config:) ⇒ PageParser
Returns a new instance of PageParser.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/request_handler/page_parser.rb', line 10 def initialize(params:, page_config:) missing_arguments = [] missing_arguments << { params: "is missing" } if params.nil? missing_arguments << { page_config: "is missing" } if page_config.nil? raise MissingArgumentError.new(missing_arguments) unless missing_arguments.empty? = params.fetch("page") { {} } raise PageParamsError.new(page: "must be a Hash") unless .is_a?(Hash) @config = page_config end |
Instance Method Details
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/request_handler/page_parser.rb', line 22 def run cfg = deep_to_h(config).keys.reduce(base_page) do |memo, key| next memo if TOP_LEVEL_PAGE_KEYS.include?(key) memo.merge!("#{key}#{separator}number".to_sym => extract_number(prefix: key), "#{key}#{separator}size".to_sym => extract_size(prefix: key)) end (cfg) cfg end |