Sha256: c3190e3566b9e40036c4f4bb960894b558e6d8cfb48dcea3bf83989b1cff8150
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
require "hashie" require "forwardable" module Redd # A bunch of objects that can hold properties. module Objects # A base for all objects to inherit from. class Base < Hashie::Hash include Hashie::Extensions::MergeInitializer include Hashie::Extensions::MethodReader include Hashie::Extensions::MethodQuery include Hashie::Extensions::DeepMerge # The `delete` method is called `delete_path` because it conflicts with # Hash#delete. extend Forwardable def_delegators :@client, :get, :post, :put, :delete_path # @!attribute [r] client # @return [Clients::Base] The client that used to make requests. attr_reader :client # @param [Clients::Base] client The client instance. # @param [Hash] attributes A hash of attributes. def initialize(client, attributes = {}) @client = client super(attributes) end # Define an alias for a property. # @param [Symbol] new_name The alias. # @param [Symbol] old_name The existing property. def self.alias_property(new_name, old_name) define_method(new_name) { send(old_name) } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
redd-0.7.4 | lib/redd/objects/base.rb |