Sha256: b92e998b0895978978cddc440f85cee4f61ec4bf96139eb94048a34454eb9b5d
Contents?: true
Size: 918 Bytes
Versions: 1
Compression:
Stored size: 918 Bytes
Contents
# frozen_string_literal: true module SolidusRecommendations class Client ## # Defines a method to access class instance. # # @example Create a namespace for products # add_recommendable :products #=> SolidusRecommendations::Client::Products.new # def self.add_recommendable(name) converted = name.to_s.split('_').map(&:capitalize).join klass = SolidusRecommendations::Recommendable.const_get(converted) create_instance(klass) end ## # Dynamically creates an attr_reader for each client space # and sets it to the initalized values # def self.create_instance(klass) reader = klass.to_s.split('::').last.downcase define_method(reader.to_sym) { klass.new } end ## # Methods for product recommendations. # # @return [SolidusRecommendations::Recommendable::Products] # add_recommendable :products end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solidus_recommendations-0.0.2 | lib/solidus_recommendations/client.rb |