Sha256: 01d3ce661ca56a7c75ab4329470ad847ffd104b331f56c5ed262b34116fea2fe

Contents?: true

Size: 544 Bytes

Versions: 13

Compression:

Stored size: 544 Bytes

Contents

module ActiveMocker

  class Field

    attr_reader :name, :type, :options

    def initialize(name, type, options)
      @name    = name
      @type    = type
      @options = options
      create_option_methods
    end

    def to_h
      {name: name, type: type, options: options}
    end

    alias_method :to_hash, :to_h

    def create_option_methods
      options.each do |opt|
        key, value = opt.first
        self.instance_variable_set("@#{key}", value)
        self.class.send(:attr_accessor, key)
      end
    end

  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
active_mocker-1.2 lib/active_mocker/field.rb
active_mocker-1.2.pre.11 lib/active_mocker/field.rb
active_mocker-1.2.pre.10 lib/active_mocker/field.rb
active_mocker-1.2.pre.9 lib/active_mocker/field.rb
active_mocker-1.2.pre.8 lib/active_mocker/field.rb
active_mocker-1.2.pre.7 lib/active_mocker/field.rb
active_mocker-1.2.pre.6 lib/active_mocker/field.rb
active_mocker-1.2.pre.5 lib/active_mocker/field.rb
active_mocker-1.2.pre.4 lib/active_mocker/field.rb
active_mocker-1.2.pre.3 lib/active_mocker/field.rb
active_mocker-1.2.pre.2 lib/active_mocker/field.rb
active_mocker-1.2.pre.1 lib/active_mocker/field.rb
active_mocker-1.2.pre lib/active_mocker/field.rb