Sha256: 700d6fafaf208ab892e42877ad3ad896fd27cc66c3f877e47060c4ac210c6812

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

module Yao::Resources
  class Meter < Base

    include ProjectAssociationable

    friendly_attributes :meter_id, :name, :user_id, :resource_id, :source, :type, :unit

    # @return [String]
    def id
      meter_id
    end

    # @return [Yao::Resources::Resource]
    def resource
      @resource ||= Yao::Resource.get(resource_id)
    end

    # @return [Yao::Resources::User]
    def user
      @user ||= Yao::User.get(user_id)
    end

    self.service        = "metering"
    self.api_version    = "v2"
    self.resources_name = "meters"

    class << self
      private

      # override Yao::Resources::RestfullyAccessible.resource_from_json
      # @param json [Hash]
      # @return [Yao::Resources::Meter]
      def resource_from_json(json)
        new(json)
      end

      # override Yao::Resources::RestfullyAccessible.resources_from_json
      # @param json [Array<Hash>]
      # @return [Array<Yao::Resources::Meter>]
      def resources_from_json(json)
        json.map{|d| new(d)}
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
yao-0.21.0 lib/yao/resources/meter.rb
yao-0.20.0 lib/yao/resources/meter.rb
yao-0.19.0 lib/yao/resources/meter.rb
yao-0.18.0 lib/yao/resources/meter.rb
yao-0.17.0 lib/yao/resources/meter.rb
yao-0.16.0 lib/yao/resources/meter.rb