Sha256: ee6956ccc77ec910eaefc76ff60630baeda5586c2ef51d07f1854d7ba8d570f0

Contents?: true

Size: 552 Bytes

Versions: 3

Compression:

Stored size: 552 Bytes

Contents

module Rasti
  class Model
    class Attribute

      attr_reader :name, :type

      def initialize(name, type, options={})
        @name = name
        @type = type
        @options = options
      end

      def default?
        options.key? :default
      end

      def default_value
        options.fetch(:default)
      end

      def to_s
        "#{self.class}[name: #{name.inspect}, type: #{type.inspect}, options: #{options.inspect}]"
      end
      alias_method :inspect, :to_s

      private

      attr_reader :options

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rasti-model-2.0.0 lib/rasti/model/attribute.rb
rasti-model-1.0.1 lib/rasti/model/attribute.rb
rasti-model-1.0.0 lib/rasti/model/attribute.rb