Sha256: 0e66f38b04853fc2db3392a61292752e9f08d417540ac7b9f47a1e186d4cb460

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

module NetSuite
  module Support
    module Fields
      include Attributes

      def self.included(base)
        base.send(:extend, ClassMethods)
      end

      module ClassMethods

        def fields(*args)
          if args.empty?
             @fields ||= Set.new
          else
            args.each do |arg|
              field arg
            end
          end
        end

        def field(name)
          name_sym = name.to_sym
          fields << name_sym
          define_method(name_sym) do
            attributes[name_sym]
          end

          define_method("#{name_sym}=") do |value|
            attributes[name_sym] = value
          end
        end

        def read_only_fields(*args)
          if args.empty?
             @read_only_fields ||= Set.new
          else
            args.each do |arg|
              read_only_field arg
            end
          end
        end

        def read_only_field(name)
          name_sym = name.to_sym
          read_only_fields << name_sym
          field name
        end

      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
netsuite-0.0.18 lib/netsuite/support/fields.rb
netsuite-0.0.17 lib/netsuite/support/fields.rb
netsuite-0.0.16 lib/netsuite/support/fields.rb
netsuite-0.0.15 lib/netsuite/support/fields.rb
netsuite-0.0.14 lib/netsuite/support/fields.rb
netsuite-0.0.13 lib/netsuite/support/fields.rb
netsuite-0.0.12 lib/netsuite/support/fields.rb
netsuite-0.0.11 lib/netsuite/support/fields.rb