Sha256: 5cbf5aacf679ac00e98c92deef759713920eac974f364303a68de2ee06e20027

Contents?: true

Size: 618 Bytes

Versions: 25

Compression:

Stored size: 618 Bytes

Contents

module JsonApiClient
  module Helpers
    module Initializable
      extend ActiveSupport::Concern

      included do
        class_attribute :initializers
        self.initializers = []
      end

      module ClassMethods
        def initializer(method = nil, &block)
          self.initializers.push(method || block)
        end
      end

      def initialize(params = {})
        initializers.each do |initializer|
          if initializer.respond_to?(:call)
            initializer.call(self, params)
          else
            self.send(initializer, params)
          end
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
json_api_client-0.9.6 lib/json_api_client/helpers/initializable.rb
json_api_client-0.9.5 lib/json_api_client/helpers/initializable.rb
json_api_client-0.9.4 lib/json_api_client/helpers/initializable.rb
json_api_client-0.9.3 lib/json_api_client/helpers/initializable.rb
json_api_client-0.9.2 lib/json_api_client/helpers/initializable.rb
json_api_client-0.9.0 lib/json_api_client/helpers/initializable.rb
json_api_client-1.0.0.beta lib/json_api_client/helpers/initializable.rb
json_api_client-0.8.1 lib/json_api_client/helpers/initializable.rb
json_api_client-0.8.0 lib/json_api_client/helpers/initializable.rb
json_api_client-0.7.1 lib/json_api_client/helpers/initializable.rb
json_api_client-0.7.0 lib/json_api_client/helpers/initializable.rb
json_api_client-0.6.0 lib/json_api_client/helpers/initializable.rb
json_api_client-0.5.1 lib/json_api_client/helpers/initializable.rb
json_api_client-0.5.0 lib/json_api_client/helpers/initializable.rb
json_api_client-0.4.0 lib/json_api_client/helpers/initializable.rb
json_api_client-0.3.1 lib/json_api_client/helpers/initializable.rb
json_api_client-0.3.0 lib/json_api_client/helpers/initializable.rb
json_api_client-0.2.4 lib/json_api_client/helpers/initializable.rb
json_api_client-0.2.3 lib/json_api_client/helpers/initializable.rb
json_api_client-0.2.2 lib/json_api_client/helpers/initializable.rb