Module: FmRest::Spyke::Model::ContainerFields

Extended by:
ActiveSupport::Concern
Included in:
FmRest::Spyke::Model
Defined in:
lib/fmrest/spyke/model/container_fields.rb

Overview

This module adds support for container fields.

Class Method Summary collapse

Class Method Details

.container(name, options = {}) ⇒ Object

Defines a container field on the model.

Examples:

class Honeybee < FmRest::Spyke::Base
  container :photo, field_name: "Beehive Photo ID"
end

Parameters:

  • name (Symbol)

    the name of the container field

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :field_name (String) — default: nil

    the name of the container field in the FileMaker layout (only needed if it doesn't match the name given)



27
28
29
30
31
32
33
34
# File 'lib/fmrest/spyke/model/container_fields.rb', line 27

def container(name, options = {})
  field_name = options[:field_name] || name

  define_method(name) do
    @container_fields ||= {}
    @container_fields[name.to_sym] ||= ContainerField.new(self, field_name)
  end
end