Class: Pwl::Presenter::Json

Inherits:
Object
  • Object
show all
Defined in:
lib/pwl/presenter/json.rb

Instance Method Summary collapse

Constructor Details

#initialize(locker) ⇒ Json

Returns a new instance of Json.



4
5
6
# File 'lib/pwl/presenter/json.rb', line 4

def initialize(locker)
    @locker = locker
end

Instance Method Details

#to_sObject



8
9
10
11
12
13
14
15
# File 'lib/pwl/presenter/json.rb', line 8

def to_s
  result = {}
  %w[created last_accessed last_modified].each do |attr|
    result.store(attr.to_sym, @locker.send(attr))
  end
  result[:entries] = @locker.all.collect{|e| {:uuid => e.uuid, :name => e.name, :password => e.password}}
  result.to_json
end