Sha256: 3dce403a7a02e04aa7dad50d8e6013c638e3d38915d51dda831b84168e585c1f

Contents?: true

Size: 854 Bytes

Versions: 10

Compression:

Stored size: 854 Bytes

Contents

module RemoteResource
  class ConnectionOptions

    attr_reader :base_class

    def initialize(base_class)
      @base_class = base_class
      self.send :initialize_connection_options
    end

    def merge(options = {})
      options.each do |option, value|
        self.public_send "#{option}=", value
      end and self
    end

    def to_hash
      RemoteResource::Base::OPTIONS.each_with_object(Hash.new) do |option, hash|
        hash[option] = self.public_send option
      end
    end

    def reload
      initialize_connection_options
    end

    def reload!
      reload and self
    end

    private

    def initialize_connection_options
      RemoteResource::Base::OPTIONS.each do |option|
        self.class.send :attr_accessor, option
        self.public_send "#{option}=", base_class.public_send(option)
      end
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ddy_remote_resource-0.4.11 lib/remote_resource/connection_options.rb
ddy_remote_resource-0.4.10 lib/remote_resource/connection_options.rb
ddy_remote_resource-0.4.9 lib/remote_resource/connection_options.rb
ddy_remote_resource-0.4.8 lib/remote_resource/connection_options.rb
ddy_remote_resource-0.4.7 lib/remote_resource/connection_options.rb
ddy_remote_resource-0.4.6 lib/remote_resource/connection_options.rb
ddy_remote_resource-0.4.5 lib/remote_resource/connection_options.rb
ddy_remote_resource-0.4.4 lib/remote_resource/connection_options.rb
ddy_remote_resource-0.4.3 lib/remote_resource/connection_options.rb
ddy_remote_resource-0.4.2 lib/remote_resource/connection_options.rb