File: config.rb

package info (click to toggle)
ruby-buff-config 2.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 200 kB
  • sloc: ruby: 481; makefile: 4
file content (32 lines) | stat: -rw-r--r-- 627 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'buff/extensions'
require 'varia_model'
require 'forwardable'

module Buff
  require_relative 'config/errors'

  module Config
    class Base
      extend Forwardable
      include VariaModel

      attr_accessor :path

      def_delegator :to_hash, :slice
      def_delegator :to_hash, :slice!
      def_delegator :to_hash, :extract!

      # @param [String] path
      # @param [Hash] attributes
      def initialize(path = nil, attributes = {})
        @path = File.expand_path(path) if path

        mass_assign(attributes)
      end

      def to_hash
        super.deep_symbolize_keys
      end
    end
  end
end