Sha256: a313568d657ef70984babadf6fcc7d85b638f9622c49c928da1081c42635fa67

Contents?: true

Size: 1.09 KB

Versions: 33

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require "fmrest/spyke/container_field"

module FmRest
  module Spyke
    module Model
      # This module adds support for container fields.
      #
      module ContainerFields
        extend ::ActiveSupport::Concern

        class_methods do
          # Defines a container field on the model.
          #
          # @param name [Symbol] the name of the container field
          #
          # @option options [String] :field_name (nil) the name of the container
          #   field in the FileMaker layout (only needed if it doesn't match
          #   the name given)
          #
          # @example
          #   class Honeybee < FmRest::Spyke::Base
          #     container :photo, field_name: "Beehive Photo ID"
          #   end
          #
          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
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
fmrest-spyke-0.26.3 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.26.2 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.26.1 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.26.1.rc1 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.26.0 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.26.0.rc1 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.25.0.rc1 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.24.0 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.24.0.rc1 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.23.1 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.23.0 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.22.0 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.21.0 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.21.0.rc1 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.20.0 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.20.0.rc1 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.19.0 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.19.0.rc1 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.18.0 lib/fmrest/spyke/model/container_fields.rb
fmrest-spyke-0.18.0.rc3 lib/fmrest/spyke/model/container_fields.rb