Sha256: d7022c7594fd309e95487df0c5e2f4b6c10adf1eece4595f6d9fe9c53a04ed7b

Contents?: true

Size: 455 Bytes

Versions: 6

Compression:

Stored size: 455 Bytes

Contents

# frozen_string_literal: true

module Afterpay
  module Initializable
    def self.included(base)
      base.extend ClassMethods
    end

    def initialize(params = {})
      self.class.accessors.each do |name|
        send :"#{name}=", params[name]
      end
    end

    module ClassMethods
      def accessors
        @accessors ||= []
      end

      def attr_accessor(*args)
        accessors.push(*args)

        super
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
afterpay-0.6.0 lib/afterpay/initializable.rb
afterpay-0.5.0 lib/afterpay/initializable.rb
afterpay-0.4.0 lib/afterpay/initializable.rb
afterpay-0.3.0 lib/afterpay/initializable.rb
afterpay-0.2.0 lib/afterpay/initializable.rb
afterpay-0.1.0 lib/afterpay/initializable.rb