Class: Gem::Micro::YAMLable

Inherits:
Object
  • Object
show all
Defined in:
lib/microgem/yamlable.rb

Overview

Mainly a MacRuby workaround, because yaml transfer is broken.

Class Method Summary collapse

Class Method Details

.[](values) ⇒ Object

Initializes an instance and assigns the hash of values as its instance variables.

YAMLable[:foo => 'foo'] # => <#Gem::Micro::YAMLable:0x320154 @foo="foo">


24
25
26
27
28
# File 'lib/microgem/yamlable.rb', line 24

def [](values)
  object = new
  values.each { |k,v| object.send(:instance_variable_set, "@#{k}", v) }
  object
end

.inherited(subklass) ⇒ Object

:nodoc:



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/microgem/yamlable.rb', line 8

def inherited(subklass) #:nodoc:
  super
  
  subklass.class_eval do
    yaml_as "tag:ruby.yaml.org,2002:object:#{name}"
    
    def self.yaml_new(klass, tag, values)
      self[values]
    end
  end
end