Class: Blockhead::Marshaller

Inherits:
BasicObject
Defined in:
lib/blockhead/marshaller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ Marshaller

Returns a new instance of Marshaller.



5
6
7
8
# File 'lib/blockhead/marshaller.rb', line 5

def initialize(object)
  @attributes = {}
  @object = object
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



14
15
16
17
18
# File 'lib/blockhead/marshaller.rb', line 14

def method_missing(name, *args, &block)
  @arg = args.first
  key = OptionKey.new(name, @arg).key
  attributes[key] = ValueExtractor.new(_call(name), *args, &block).extract
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



3
4
5
# File 'lib/blockhead/marshaller.rb', line 3

def attributes
  @attributes
end

#objectObject (readonly)

Returns the value of attribute object.



3
4
5
# File 'lib/blockhead/marshaller.rb', line 3

def object
  @object
end

Instance Method Details

#marshalObject



10
11
12
# File 'lib/blockhead/marshaller.rb', line 10

def marshal
  attributes
end