Class: CommunityZero::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/community_zero/chef/metadata.rb

Overview

A quick, short metadata parser.

Author:

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ Metadata

Create a new metadata class.

Parameters:

  • content (String)

    the contents of the file to convert to a metadata entry.



27
28
29
# File 'lib/community_zero/chef/metadata.rb', line 27

def initialize(content)
  instance_eval(content)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



31
32
33
34
35
36
37
# File 'lib/community_zero/chef/metadata.rb', line 31

def method_missing(m, *args, &block)
  if args.empty?
    data[m.to_sym]
  else
    data[m.to_sym] = args.size == 1 ? args[0] : args
  end
end

Instance Method Details

#respond_to?(m) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/community_zero/chef/metadata.rb', line 39

def respond_to?(m)
  !!data[m.to_sym]
end