Sha256: 61921221e4e2927a84ca2859892fb5da7c1c31340402f86093692e59799ce35f

Contents?: true

Size: 537 Bytes

Versions: 17

Compression:

Stored size: 537 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

    def create_option_methods
      options.each do |opt|
        key, value = opt.first
        self.instance_variable_set("@#{key}", value)
        define_singleton_method(key) {instance_variable_get("@#{key}")}
      end
    end

  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
active_mocker-1.1.23 lib/active_mocker/field.rb
active_mocker-1.1.22 lib/active_mocker/field.rb
active_mocker-1.1.21 lib/active_mocker/field.rb
active_mocker-1.1.20 lib/active_mocker/field.rb
active_mocker-1.1.11 lib/active_mocker/field.rb
active_mocker-1.1.10 lib/active_mocker/field.rb
active_mocker-1.1.9 lib/active_mocker/field.rb
active_mocker-1.1.8 lib/active_mocker/field.rb
active_mocker-1.1.7 lib/active_mocker/field.rb
active_mocker-1.1.6 lib/active_mocker/field.rb
active_mocker-1.1.5 lib/active_mocker/field.rb
active_mocker-1.1.4 lib/active_mocker/field.rb
active_mocker-1.1.3 lib/active_mocker/field.rb
active_mocker-1.1.2 lib/active_mocker/field.rb
active_mocker-1.1.1 lib/active_mocker/field.rb
active_mocker-1.1.0 lib/active_mocker/field.rb
active_mocker-1.0.1 lib/active_mocker/field.rb