Sha256: 076078602cce0d413b6cb9f8f097847494e9cb8627406b4c718c8ff972fb7592

Contents?: true

Size: 806 Bytes

Versions: 1

Compression:

Stored size: 806 Bytes

Contents

module Alula
  module Video
    class BaseResource < Alula::ApiResource
      extend Alula::ResourceAttributes

      class << self
        def api_name(name = nil)
          if name
            @api_name = name
          elsif @api_name
            @api_name
          else
            superclass.api_name
          end
        end

        # Infer resource name from classname if not provided
        def resource_name(name = nil)
          if name
            @resource_name = name
          elsif @resource_name
            @resource_name
          else
            @resource_name = self.name.split('::').last.downcase.to_sym
          end
        end

        def resource_url(id = nil)
          "/#{api_name}/v1/#{resource_name}/#{id}"
        end
      end

      api_name :video
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alula-ruby-0.54.0 lib/alula/resources/video/base_resource.rb