Module: Broadway::Configurable::InstanceMethods

Defined in:
lib/broadway/mixins/configurable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



23
24
25
26
27
28
29
# File 'lib/broadway/mixins/configurable.rb', line 23

def method_missing(meth, *args, &block)
  if self.data && self.data.has_key?(meth.to_s)
    self.data[meth.to_s]
  else
    super(meth, *args, &block)
  end
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



8
9
10
# File 'lib/broadway/mixins/configurable.rb', line 8

def data
  @data
end

Instance Method Details

#configureObject

should only read the beginning of the file



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/broadway/mixins/configurable.rb', line 11

def configure
  self.content = file.read
  
  if self.content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
    self.content = self.content[($1.size + $2.size)..-1]
    
    self.data.merge!(YAML.load($1))
  end
  
  self.data ||= {}
end