Class: Cfer::BlockHash
- Defined in:
- lib/cfer/block.rb
Overview
BlockHash is a Block that responds to DSL-style properties.
Direct Known Subclasses
Constant Summary collapse
- NON_PROXIED_METHODS =
[ :parameters, :options, :lookup_output, :lookup_outputs, :__docile_undo_fallback__ ].freeze
Instance Method Summary collapse
-
#get_property(key) ⇒ Object
Gets the current value of a given property.
- #method_missing(method_sym, *arguments, &block) ⇒ Object
-
#properties(keyvals = {}) ⇒ Object
Directly sets raw properties in the underlying CloudFormation structure.
- #respond_to?(method_sym) ⇒ Boolean
Methods inherited from Block
#build_from_block, #build_from_file, #build_from_string, #include_file, #post_block, #pre_block
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/cfer/block.rb', line 86 def method_missing(method_sym, *arguments, &block) key = camelize_property(method_sym) properties key => case arguments.size when 0 if block BlockHash.new.build_from_block(&block) else raise "Expected a value or block when setting property #{key}" end when 1 arguments.first else arguments end end |
Instance Method Details
#get_property(key) ⇒ Object
Gets the current value of a given property
78 79 80 |
# File 'lib/cfer/block.rb', line 78 def get_property(key) self.fetch key end |
#properties(keyvals = {}) ⇒ Object
Directly sets raw properties in the underlying CloudFormation structure.
72 73 74 |
# File 'lib/cfer/block.rb', line 72 def properties(keyvals = {}) self.merge!(keyvals) end |
#respond_to?(method_sym) ⇒ Boolean
82 83 84 |
# File 'lib/cfer/block.rb', line 82 def respond_to?(method_sym) !non_proxied_methods.include?(method_sym) end |