Class: CanBe::Processor::Klass
- Inherits:
-
Object
- Object
- CanBe::Processor::Klass
- Defined in:
- lib/can_be/processor/klass.rb
Instance Method Summary collapse
- #create(t, *args, &block) ⇒ Object
- #find_by_types(*types) ⇒ Object
-
#initialize(klass) ⇒ Klass
constructor
A new instance of Klass.
- #instantiate(t, *args, &block) ⇒ Object
Constructor Details
#initialize(klass) ⇒ Klass
Returns a new instance of Klass.
4 5 6 7 8 |
# File 'lib/can_be/processor/klass.rb', line 4 def initialize(klass) @klass = klass @config = @klass.can_be_config @field_name = @config.field_name end |
Instance Method Details
#create(t, *args, &block) ⇒ Object
14 15 16 17 18 |
# File 'lib/can_be/processor/klass.rb', line 14 def create(t, *args, &block) set_field_on(args, t) @klass.create(*args, &block) end |
#find_by_types(*types) ⇒ Object
10 11 12 |
# File 'lib/can_be/processor/klass.rb', line 10 def find_by_types(*types) @klass.where(@field_name => types) end |
#instantiate(t, *args, &block) ⇒ Object
20 21 22 23 24 |
# File 'lib/can_be/processor/klass.rb', line 20 def instantiate(t, *args, &block) set_field_on(args, t) @klass.new(*args, &block) end |