| Module | KeyContext |
| In: |
app/models/key_context.rb
|
Key context is a module intended to be mixed in to classes requiring the notion of "key context". Concepts such as chords and scales exist as mathematical relationships absent key, but can be put into key context. Adds a key instance variable to the including class and two new methods:
# File app/models/key_context.rb, line 10
10: def self.included(klass)
11: klass.class_eval do
12: attr_accessor :key
13:
14: def in_key_of(name)
15: self.key = Key.find_by_name(name)
16: self
17: end
18: alias_method :in, :in_key_of
19:
20: def without_key
21: self.key = nil
22: self
23: end
24: end
25: end
# File app/models/key_context.rb, line 14
14: def in_key_of(name)
15: self.key = Key.find_by_name(name)
16: self
17: end