Sha256: 3c3d2fec8865c03e3c4b1ccae3ae507df7c1fc67f2671516014d21a863d3ca0f

Contents?: true

Size: 478 Bytes

Versions: 1

Compression:

Stored size: 478 Bytes

Contents

# frozen_string_literal: true

require "config_mapper/mapper"

module ConfigMapper

  # Configuration proxy for an Object.
  #
  class ObjectMapper < Mapper

    def initialize(object)
      @object = object
    end

    def path(key)
      ".#{key}"
    end

    def get(key)
      @object.public_send(key.to_s)
    end

    def set(key, value)
      @object.public_send("#{key}=", value)
    end

    def can_set?(key)
      @object.respond_to?("#{key}=")
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
config_mapper-1.8.0 lib/config_mapper/object_mapper.rb