Sha256: eb5ac1ede4957001c863938723598169f68752d6c680503e2dde5fe358d6234d

Contents?: true

Size: 612 Bytes

Versions: 1

Compression:

Stored size: 612 Bytes

Contents

package org.fresnoframework.extensions.fields

# Add the ability to have fields a la attr_accessor in Ruby
# Implementation based on: http://www.mirah.org/wiki/Macros
#
#   class Robot
#     implements Fields
#
#     field :name, :string
#     field :team, :int
#   end
#   
#   r = Robot.new
#   r.name = "Mr. Awesometron 9000"
#   puts r
#   # => "Mr. Awesometron 9000"
#
interface Fields do
  macro def field(name_node, type)
    name = name_node.string_value

    quote do
      def `name`
        @`name`
      end

      def `"#{name}_set"`(value:`type`)
        @`name` = value
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fresno-0.0.3-java src/extensions/fields.mirah