lib/eco/api/session/config/people.rb in eco-helpers-0.7.2 vs lib/eco/api/session/config/people.rb in eco-helpers-0.8.1
- old
+ new
@@ -1,18 +1,11 @@
module Eco
module API
class Session
class Config
- class People < Hash
- attr_reader :config
+ class People < BaseConfig
- def initialize(root:)
- super(nil)
- @root = root
- @config = @root
- end
-
def cache=(file)
self["cache"] = file
end
def cache
@@ -78,28 +71,25 @@
def presets_map
self["presets_map"]
end
- # Defines an `ParserSerializer` for a `PersonParser` of certain `format`
- # @param format [Symbol] the target format this parser/serializer is made for.
- def add_parser(format: :csv)
- parsers[format] ||= Eco::API::Common::People::PersonParser.new
- parsers[format].tap do |prs|
- yield(prs, config)
- end
- end
-
# @return [Hash] with defined pairs format `key` and Person parsers.
def parsers
self["parsers"] ||= {}
end
# The person parser/serializer for a given format (default `csv`).
# @param format [Symbol] the format this parser/serializer recognizes.
# @return [Eco::API::Common::People::PersonParser] parser/serializer for the defined `format`.
def parser(format: :csv)
- parsers[format]
+ prs = parsers[format] ||= Eco::API::Common::People::PersonParser.new
+ if block_given?
+ yield(prs)
+ self
+ else
+ prs
+ end
end
end
end
end