Module: EasyType::Type::ClassMethods
- Defined in:
- lib/easy_type/type.rb
Instance Method Summary (collapse)
- - (Object) define_os_command_method(method_or_command)
-
- (Group) group(group_name = :default, &block)
define a group of parameters.
-
- (Group) groups
Return the groups the type contains.
-
- (Object) on_create(&block)
end.
-
- (Object) on_destroy(&block)
end.
-
- (Object) on_modify(&block)
end.
- - (Object) parameter(parameter_name) (also: #property)
- - (Object) process_group_entry(entry)
- - (Object) set_command(method_or_command)
-
- (Object) to_get_raw_resources(&block)
end.
Instance Method Details
- (Object) define_os_command_method(method_or_command)
116 117 118 119 120 121 122 |
# File 'lib/easy_type/type.rb', line 116 def define_os_command_method(method_or_command) eigenclass = class << self; self; end eigenclass.send(:define_method, method_or_command) do | *args| command = args.dup.unshift(method_or_command) Puppet::Util::Execution.execute( command) end end |
- (Group) group(group_name = :default, &block)
define a group of parameters. A group means a change in one of it's members all the information in the group is added tot the command
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/easy_type/type.rb', line 41 def group(group_name = :default, &block) include EasyType::FileIncluder @group_name = group_name # make it global @groups ||= EasyType::Group.new alias :orig_parameter :parameter alias :orig_property :property def parameter(parameter_name) process_group_entry(include_file("puppet/type/#{name}/#{parameter_name}")) end def property(property_name) process_group_entry(include_file("puppet/type/#{name}/#{property_name}")) end def process_group_entry(entry) @groups.add(name,entry) end yield if block alias :parameter :orig_parameter alias :property :orig_property end |
- (Group) groups
Return the groups the type contains
73 74 75 76 |
# File 'lib/easy_type/type.rb', line 73 def groups @groups ||= EasyType::Group.new @groups end |
- (Object) on_create(&block)
end
138 139 140 |
# File 'lib/easy_type/type.rb', line 138 def on_create(&block) define_method(:on_create, &block) if block end |
- (Object) on_destroy(&block)
end
156 157 158 |
# File 'lib/easy_type/type.rb', line 156 def on_destroy(&block) define_method(:on_destroy, &block) if block end |
- (Object) on_modify(&block)
end
174 175 176 |
# File 'lib/easy_type/type.rb', line 174 def on_modify(&block) define_method(:on_modify, &block) if block end |
- (Object) parameter(parameter_name) Also known as: property
86 87 88 |
# File 'lib/easy_type/type.rb', line 86 def parameter(parameter_name) process_group_entry(include_file("puppet/type/#{name}/#{parameter_name}")) end |
- (Object) process_group_entry(entry)
59 60 61 |
# File 'lib/easy_type/type.rb', line 59 def process_group_entry(entry) @groups.add(name,entry) end |
- (Object) set_command(method_or_command)
105 106 107 108 109 110 111 112 113 |
# File 'lib/easy_type/type.rb', line 105 def set_command(method_or_command) method_or_command = method_or_command.to_s if RUBY_VERSION == "1.8.7" unless methods.include?(method_or_command) define_os_command_method(method_or_command) end define_method(:command) do | *args | self.class.send(method_or_command, *args) end end |
- (Object) to_get_raw_resources(&block)
end
191 192 193 194 |
# File 'lib/easy_type/type.rb', line 191 def to_get_raw_resources(&block) eigenclass = class << self; self; end eigenclass.send(:define_method, :get_raw_resources, &block) end |