Class: Composed::Keywords
- Inherits:
-
Object
- Object
- Composed::Keywords
- Defined in:
- lib/composed/keywords.rb
Instance Method Summary collapse
- #[]=(keyword, value) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ Keywords
constructor
A new instance of Keywords.
- #merge(args) ⇒ Object
Constructor Details
#initialize ⇒ Keywords
Returns a new instance of Keywords.
4 5 6 |
# File 'lib/composed/keywords.rb', line 4 def initialize @injected = {} end |
Instance Method Details
#[]=(keyword, value) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/composed/keywords.rb', line 8 def []=(keyword, value) raise ArgumentError, " Cannot inject keyword argument \\\"\#{keyword}\\\" more than once.\"\n ERROR\n @injected[keyword] = value\nend\n" if @injected.key?(keyword) |
#empty? ⇒ Boolean
23 24 25 |
# File 'lib/composed/keywords.rb', line 23 def empty? @injected.empty? end |
#merge(args) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/composed/keywords.rb', line 15 def merge(args) @injected.each do |key, value| args[key] = value.call unless args.key?(key) end args end |