Sha256: 45b29279f863543dc09bb53a3cb7a04dced835ac2328cb1b351158a67b776a51

Contents?: true

Size: 571 Bytes

Versions: 2

Compression:

Stored size: 571 Bytes

Contents

# A base class for models
#
# @abstract
class Basecamp3::Model
  REQUIRED_FIELDS = []

  def initialize(data = {})
    data.each do |attr, value|
      instance_variable_set("@#{attr}", value)
    end
  end

  protected

  # Validates if the given data contain the required attributes.
  #
  # @param [Hash] data the data to send in the request
  #
  # @raise [StandardError] raises an error if required parameter is missing
  def self.validate_required(data)
    self::REQUIRED_FIELDS.each { |f| raise "Missing required parameter #{f}" if data[f.to_sym].nil? }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
basecamp3-0.1.4 lib/basecamp3/model.rb
basecamp3-0.1.3 lib/basecamp3/model.rb