Module: EvernoteOAuth::StoreAttachable
- Defined in:
- lib/evernote_oauth/store_attachable.rb
Instance Method Summary collapse
- #attach_note_store(*field_symbols) ⇒ Object
- #attach_store(type, *field_symbols) ⇒ Object
- #attach_user_store(*field_symbols) ⇒ Object
Instance Method Details
#attach_note_store(*field_symbols) ⇒ Object
7 8 9 |
# File 'lib/evernote_oauth/store_attachable.rb', line 7 def attach_note_store(*field_symbols) attach_store('note', *field_symbols) end |
#attach_store(type, *field_symbols) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/evernote_oauth/store_attachable.rb', line 11 def attach_store(type, *field_symbols) field_symbols.each do |fs| define_method(fs) do original = "@#{fs}".to_sym target = "@#{fs}_with_#{type}_stores".to_sym with_stores = ( instance_variable_get(target) || begin store_name = "#{type}_store" store = eval(store_name) [instance_variable_get(original)].flatten.each{|n| n.define_singleton_method(store_name.to_sym){store} } end ) instance_variable_set(target, with_stores) end end end |
#attach_user_store(*field_symbols) ⇒ Object
3 4 5 |
# File 'lib/evernote_oauth/store_attachable.rb', line 3 def attach_user_store(*field_symbols) attach_store('user', *field_symbols) end |