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.



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

def initialize(block)
  instance_eval(&block)
end

Instance Attribute Details

#fieldsObject

Returns the value of attribute fields.



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

def fields
  @fields
end

#modelObject

Returns the value of attribute model.



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

def model
  @model
end

#requestObject

Returns the value of attribute request.



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

def request
  @request
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#attribute(name, &block) ⇒ Object



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

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

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



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

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

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



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

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

#loggerObject



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

def logger; Traim.logger  end