Sha256: e36859bf9eb86045e99fb08f12361a33d2ceebe3a9f2101d69a5d0f061068fb4

Contents?: true

Size: 665 Bytes

Versions: 3

Compression:

Stored size: 665 Bytes

Contents

require 'concern_builder'
require 'bidu/core_ext'

class Danica::Common
  class VariablesBuilder < ::ConcernBuilder
    attr_reader :instance

    def init
      attr_names.each do |name|
        add_setter(name)
        add_reader(name)
        instance.send(:variables_names) << name
      end
    end

    private

    def add_setter(name)
      code = <<-CODE
        variables_hash[:#{name}] = wrap_value(value)
        @variables = variables_hash.values
      CODE
      add_method("#{name}=(value)", code)
    end

    def add_reader(name)
      code = <<-CODE
        variables_hash[:#{name}]
      CODE
      add_method("#{name}", code)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
danica-2.0.2 lib/danica/common/variables_builder.rb
danica-2.0.1 lib/danica/common/variables_builder.rb
danica-2.0.0 lib/danica/common/variables_builder.rb