Sha256: dd2d7f228f3ab242c043ba9fa7383ee655282dcd3ba76ec51c4efc9f0c9c1b6e
Contents?: true
Size: 894 Bytes
Versions: 4
Compression:
Stored size: 894 Bytes
Contents
require 'active_support' require 'active_support/core_ext/class/attribute' require 'biggs/extractor' require 'biggs/formatter' module Biggs module Concern extend ActiveSupport::Concern included do class_attribute :biggs_config, default: {} end class_methods do def biggs(method_name=:postal_address, options={}) self.define_method(method_name) do formatter = self.biggs_config[method_name][:formatter] extractor = self.biggs_config[method_name][:extractor] formatter.format( extractor.get_value(self, :country), extractor.get_values(self) ) end self.biggs_config = self.biggs_config.dup self.biggs_config[method_name] = { formatter: Biggs::Formatter.new(options), extractor: Biggs::Extractor.new(options) } end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
biggs-0.7.0 | lib/biggs/concern.rb |
biggs-0.6.0 | lib/biggs/concern.rb |
biggs-0.5.1 | lib/biggs/concern.rb |
biggs-0.5.0 | lib/biggs/concern.rb |