[Ironruby-core] Accessing the return value from a Dsl

Paul Cowan lists at ruby-forum.com
Mon Mar 16 06:51:00 EDT 2009


I am trying to create a Dsl which will have instances that live in
individual Dsl .rb files and then run them from the CLR.

I want to create and set the values of the Clr object in IronRuby and
then somehow have access to the CLR object after the .rb Dsl instance
file has run.

Here is my Clr object which is very simple at the moment:

namespace Horn.Core.Dsl
    public class BuildMetaData : IBuildMetaData
        public string Description { get; set; }

I have the following module which I am using to specify my Dsl and which
will create an instance of the BuildMetaData specified above:

module MetaBuilder
  module Dsl
    module Main
      attr_accessor :metadata
      def install(name, &block)
        @metadata = Horn::Core::Dsl::BuildMetaData.new
        yield self if block_given?

      def description(desc)
         @metadata.Description = desc

      def get_metadata


include MetaBuilder::Dsl::Main

I somehow want to be able to get the @metadata property from the Clr
code after an instance of the Dsl has ran.

An instance of the Dsl looks like this currently:

install :horn do
  description "A .NET build and dependency manager"

My C# code looks like this currently:

var engine = Ruby.CreateEngine();
var klass = engine.Runtime.Globals.GetVariable("get_metadata");

Is there anyway I can get at the @metadata property without having to
pollute the Dsl instance?

For that matter is my approach reasonable or is there perhaps a better

Thanks in advance

Posted via http://www.ruby-forum.com/.

More information about the Ironruby-core mailing list