Sha256: bbbf76d040ce6f3d8b5818d0dd3e90eb563f03ef392a3702420eeefbe36a03bf
Contents?: true
Size: 723 Bytes
Versions: 4
Compression:
Stored size: 723 Bytes
Contents
module CanBe module Processor class Klass def initialize(klass) @klass = klass @config = @klass.can_be_config @field_name = @config.field_name end def find_by_types(*types) @klass.where(@field_name => types) end def create(t, *args, &block) set_field_on(args, t) @klass.create(*args, &block) end def instantiate(t, *args, &block) set_field_on(args, t) @klass.new(*args, &block) end private def set_field_on(args, type) if args[0] args[0][@field_name.to_sym] = type else args[0] = { @field_name.to_sym => type } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
can_be-0.4.0 | lib/can_be/processor/klass.rb |
can_be-0.3.0 | lib/can_be/processor/klass.rb |
can_be-0.2.1 | lib/can_be/processor/klass.rb |
can_be-0.2.0 | lib/can_be/processor/klass.rb |