Class: Traim::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/traim.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ Helper

Returns a new instance of Helper.



448
449
450
# File 'lib/traim.rb', line 448

def initialize(block)
  instance_eval(&block)
end

Instance Attribute Details

#fieldsObject

Returns the value of attribute fields.



456
457
458
# File 'lib/traim.rb', line 456

def fields
  @fields
end

#modelObject

Returns the value of attribute model.



455
456
457
# File 'lib/traim.rb', line 455

def model
  @model
end

#requestObject

Returns the value of attribute request.



453
454
455
# File 'lib/traim.rb', line 453

def request
  @request
end

#statusObject

Returns the value of attribute status.



454
455
456
# File 'lib/traim.rb', line 454

def status
  @status
end

Instance Method Details

#attribute(name, &block) ⇒ Object



459
460
461
# File 'lib/traim.rb', line 459

def attribute(name, &block)
  fields << {name: name, type: 'attribute', block: block} 
end

#has_many(name, options = {}, &block) ⇒ Object



462
463
464
# File 'lib/traim.rb', line 462

def has_many(name, options={}, &block)
  fields << {name: name, type: 'association', resource: options[:resource], block: block}
end

#has_one(name, options = {}, &block) ⇒ Object



465
466
467
# File 'lib/traim.rb', line 465

def has_one(name, options={}, &block)
  fields << {name: name, type: 'connection', resource: options[:resource], block: block}
end

#loggerObject



451
# File 'lib/traim.rb', line 451

def logger; Traim.logger  end