Module: EasyType::Type
- Defined in:
- lib/easy_type/type.rb
Overview
This module contains all extensions used by EasyType within the type
To use it, include the following statement in your type
include ::EasyType::Type
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #all_property_classes ⇒ Object
-
#commands ⇒ Array
Return the defined commands for the type.
-
#groups ⇒ Group
Return the groups the type contains.
- #method_missing(meth, *args, &block) ⇒ Object
- #respond_to?(meth, include_private = false) ⇒ Boolean
- #to_manifest ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/easy_type/type.rb', line 37 def method_missing(meth, *args, &block) variable = meth.to_sym if known_attribute(variable) self[variable] else super # You *must* call super if you don't handle the # method, otherwise you'll mess up Ruby's method # lookup. end end |
Class Method Details
.included(parent) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/easy_type/type.rb', line 27 def self.included(parent) return if parent.is_a?(EasyType::Type::ClassMethods) include ::EasyType::FileIncluder parent.extend(ClassMethods) include_file('easy_type/disable_corrective_ensure.rb', binding) include_file('easy_type/disable_corrective_change.rb', binding) end |
Instance Method Details
#all_property_classes ⇒ Object
96 97 98 |
# File 'lib/easy_type/type.rb', line 96 def all_property_classes self.class.properties end |
#commands ⇒ Array
Return the defined commands for the type
92 93 94 |
# File 'lib/easy_type/type.rb', line 92 def commands self.class.instance_variable_get(:@commands) end |
#groups ⇒ Group
Return the groups the type contains
83 84 85 |
# File 'lib/easy_type/type.rb', line 83 def groups self.class.groups end |
#respond_to?(meth, include_private = false) ⇒ Boolean
69 70 71 72 73 74 75 76 |
# File 'lib/easy_type/type.rb', line 69 def respond_to?(meth, include_private = false) variable = meth.to_sym if known_attribute(variable) true else super end end |
#to_manifest ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/easy_type/type.rb', line 48 def to_manifest # Collect list of attributes to align => and move ensure first attr = parameters.keys attr_max = attr.inject(0) { |max, k| k.to_s.length > max ? k.to_s.length : max } attr.sort! if attr.first != :ensure && attr.include?(:ensure) attr.delete(:ensure) attr.unshift(:ensure) end attributes = attr.collect do |k| v = self[k] format(" %-#{attr_max}s => %s,\n", k, Puppet::Parameter.format_value_for_display(v)) end.join escaped = title.gsub(/'/, "\\\\'") format("%s { '%s':\n%s}", type.to_s.downcase, escaped, attributes) end |