Method: AnkiRecord::Note#method_missing
- Defined in:
- lib/anki_record/note/note.rb
#method_missing(method_name, field_content = nil) ⇒ Object
Overrides BasicObject#method_missing and creates “ghost methods”
The ghost methods are the setters and getters for the note field values.
For example, if the note type has a field called “front” then there will be two ghost methods: front and front=.
45 46 47 48 49 50 51 52 |
# File 'lib/anki_record/note/note.rb', line 45 def method_missing(method_name, field_content = nil) raise NoMethodError, "##{method_name} is not defined or a ghost method" unless respond_to_missing? method_name method_name = method_name.to_s return @field_contents[method_name] unless method_name.end_with?("=") @field_contents[method_name.chomp("=")] = field_content end |