Sha256: 47a214c1fa775c504bbf666307e480ad390f247aab3c3a5d71270e057c8b0e87

Contents?: true

Size: 619 Bytes

Versions: 4

Compression:

Stored size: 619 Bytes

Contents

# frozen_string_literal: true

require 'readymade/response'

module Readymade
  class Action
    class NonKeywordArgumentsError < StandardError; end

    def self.call(*args, &block)
      new(*args, &block).call
    end

    attr_reader :args, :data

    def initialize(**args)
      raise NonKeywordArgumentsError if args.present? && !args.is_a?(Hash)

      @args = @data = args

      @args.each do |name, value|
        instance_variable_set("@#{name}", value)
      end

      # yield if block_given?
    end

    def call; end

    def response(status, *args)
      Response.new(status, *args)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
readymade-0.1.3 lib/readymade/action.rb
readymade-0.1.2 lib/readymade/action.rb
readymade-0.1.1 lib/readymade/action.rb
readymade-0.1.0 lib/readymade/action.rb