Class: Composed::Keywords

Inherits:
Object
  • Object
show all
Defined in:
lib/composed/keywords.rb

Instance Method Summary collapse

Constructor Details

#initializeKeywords

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

Raises:

  • (ArgumentError)


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

Returns:

  • (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