class Wutang::Interface
Attributes
config[R]
persistence[R]
Public Class Methods
new()
click to toggle source
# File lib/wutang/interface.rb, line 5 def initialize @config = Config.new.attributes end
Public Instance Methods
create(attributes)
click to toggle source
# File lib/wutang/interface.rb, line 17 def create(attributes) Entry.new(attributes, Persistence.generate_filename).tap do |entry| persistence.write entry.path, entry.as_json end end
entries()
click to toggle source
# File lib/wutang/interface.rb, line 13 def entries persistence.all end
find(entry_id)
click to toggle source
# File lib/wutang/interface.rb, line 37 def find(entry_id) entries.detect { |entry| entry.path == entry_id } end
search(criteria)
click to toggle source
# File lib/wutang/interface.rb, line 30 def search(criteria) entries.select do |entry| attributes = entry.attributes attributes.keys.any? { |key| attributes[key] =~ /#{criteria}/ } end end
update(entry, updates)
click to toggle source
# File lib/wutang/interface.rb, line 23 def update(entry, updates) entry.tap do entry.attributes.merge! updates persistence.write entry.path, entry.as_json end end