Sha256: 03dfcee2c23b680fabfc78e5b66f73be8db7aaa31184980f240e21f242c1aa11
Contents?: true
Size: 723 Bytes
Versions: 4
Compression:
Stored size: 723 Bytes
Contents
require "pluck_map/attribute" require "pluck_map/attributes" module PluckMap class AttributeBuilder < BasicObject def self.build(model:, &block) attributes = [] builder = self.new(attributes, model) if block.arity == 1 block.call(builder) else builder.instance_eval(&block) end Attributes.new(attributes) end def initialize(attributes, model) @attributes = attributes @model = model end def method_missing(attribute_name, *args) options = args.extract_options! options[:value] = args.first unless args.empty? @attributes.push Attribute.new(attribute_name, @model, options) :attribute_added end end end
Version data entries
4 entries across 4 versions & 1 rubygems