Module: Vessel::Cargo::Fieldable

Included in:
Vessel::Cargo
Defined in:
lib/vessel/cargo/fieldable.rb

Instance Method Summary collapse

Instance Method Details

#field(name, *rest) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vessel/cargo/fieldable.rb', line 14

def field(name, *rest, &)
  options = rest.last.is_a?(Hash) ? rest.pop : {}
  service = options.delete(:service)
  field = Field.new(name: name, value: options[:value], context: self, **options, &)
  value = field.apply
  if service
    fields.service[name.to_sym] = value
  else
    fields[field.name] = value
  end
end

#fieldsObject



10
11
12
# File 'lib/vessel/cargo/fieldable.rb', line 10

def fields
  @fields ||= Fields.new
end