Sha256: 17c57394962177ae7513fdf34bd46aa562aaafe13d8b84a38018f1b790c64a05

Contents?: true

Size: 594 Bytes

Versions: 1

Compression:

Stored size: 594 Bytes

Contents

module Norikra
  class Target
    attr_accessor :name, :fields, :auto_field

    def self.valid?(target_name)
      target_name =~ /^[a-zA-Z]([_a-zA-Z0-9]*[a-zA-Z0-9])?$/
    end

    def initialize(name, fields=[], auto_field=true)
      @name = name
      @fields = fields
      @auto_field = !!auto_field
    end

    def to_s
      @name
    end

    def to_hash
      {:name => @name, :auto_field => @auto_field}
    end

    def ==(other)
      self.class == other.class ? self.name == other.name : self.name == other.to_s
    end

    def auto_field?
      @auto_field
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
norikra-0.0.14-java lib/norikra/target.rb