Module: Ghaki::Meta::Builder::ClassMethods

Defined in:
lib/ghaki/meta/builder.rb

Instance Method Summary collapse

Instance Method Details

#attr_meta_builder(*tokens) ⇒ Object

Declare meta builder attributes.



37
38
39
40
41
42
43
44
45
46
# File 'lib/ghaki/meta/builder.rb', line 37

def attr_meta_builder *tokens
  @meta_builders ||= {}
  tokens.each do |token|
    @meta_builders[token] = nil
    module_eval <<-"END"
      def #{token}      ; @#{token}       end
      def #{token}= val ; @#{token} = val end
    END
  end
end

#meta_buildersObject

Getter for the meta builder helper object.



32
33
34
# File 'lib/ghaki/meta/builder.rb', line 32

def meta_builders
  @meta_builders ||= {}
end

#set_meta_builder(pairs) ⇒ Object

Assign classes to meta builder attributes.



49
50
51
52
53
54
# File 'lib/ghaki/meta/builder.rb', line 49

def set_meta_builder pairs
  pairs.each_pair do |token,klass|
    attr_meta_builder(token) unless meta_builders.has_key?(token)
    self.meta_builders[token] = klass
  end
end