Sha256: 3b7d4585e77d9f6585e8f8a61938cdf64630964ca2dcc44d01a765c4168e499c
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 KB
Contents
require "billys_billing/association" module BillysBilling class Base extend BillysBilling::Association attr_accessor :attrs alias :to_hash :attrs # Define methods that retrieve the value from an initialized instance variable Hash, using the attribute as a key # # @overload self.lazy_attr_reader(attr) # @param attr [Symbol] # @overload self.lazy_attr_reader(attrs) # @param attrs [Array<Symbol>] def self.lazy_attr_reader(*attrs) attrs.each do |attribute| class_eval do define_method attribute do @attrs[attribute.to_s] end end end end # Initializes a new Base object # # @param attrs [Hash] # @return [Twitter::Base] def initialize(attrs={}) attrs.delete_if{|k,v| v.nil?}.each do |key, value| self.send("#{key}=".to_sym, value) # instance_variable_set("@#{key}", value) end end # Initializes a new Base object # # @param method [String, Symbol] Message to send to the object def [](method) self.__send__(method.to_sym) rescue NoMethodError nil end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
billysbilling-rails-1.1.2 | lib/billys_billing/base.rb |
billysbilling-rails-1.1.1 | lib/billys_billing/base.rb |
billysbilling-rails-1.1.0 | lib/billys_billing/base.rb |