Sha256: bebc11a99c32ab20a3cb30018b5494db63927054ad6a8397458983cc415fb0f0

Contents?: true

Size: 437 Bytes

Versions: 2

Compression:

Stored size: 437 Bytes

Contents

module ActsAsApi
  #
  class ApiTemplate < Hash

    def options_for(key)
      @options[key]
    end
    
    def option_for(key, value)
      @options[key][value] if @options[key]
    end

    def add(val, options = {})
      item_key = (options[:as] || val).to_sym
      
      self[item_key] = val
      
      @options ||= {}
      @options[item_key] = options
    end

    def remove(key)
      self.delete(key)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acts_as_api-0.3.2 lib/acts_as_api/api_template.rb
acts_as_api-0.3.1 lib/acts_as_api/api_template.rb