Class: TentD::Model::App
- Inherits:
-
Object
- Object
- TentD::Model::App
- Includes:
- DataMapper::Resource, RandomPublicId, Serializable, UserScoped
- Defined in:
- lib/tentd/model/app.rb
Class Method Summary collapse
- .create_from_params(params) ⇒ Object
- .public_attributes ⇒ Object
- .update_from_params(id, params) ⇒ Object
Instance Method Summary collapse
Methods included from UserScoped
Methods included from RandomPublicId
Class Method Details
.create_from_params(params) ⇒ Object
33 34 35 |
# File 'lib/tentd/model/app.rb', line 33 def self.create_from_params(params) create(params.slice(:name, :description, :url, :icon, :redirect_uris, :scopes)) end |
.public_attributes ⇒ Object
44 45 46 |
# File 'lib/tentd/model/app.rb', line 44 def self.public_attributes [:name, :description, :url, :icon, :scopes, :redirect_uris] end |
.update_from_params(id, params) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/tentd/model/app.rb', line 37 def self.update_from_params(id, params) app = first(:id => id) return unless app app.update(params.slice(:name, :description, :url, :icon, :redirect_uris, :scopes)) app end |
Instance Method Details
#as_json(options = {}) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/tentd/model/app.rb', line 52 def as_json( = {}) attributes = super if [:mac] [:mac_key, :mac_key_id, :mac_algorithm].each { |key| attributes[key] = send(key) } end attributes[:authorizations] = .all.map { |a| a.as_json(.merge(:self => nil)) } Array([:exclude]).each { |k| attributes.delete(k) if k } attributes end |
#auth_details ⇒ Object
48 49 50 |
# File 'lib/tentd/model/app.rb', line 48 def auth_details attributes.slice(:mac_key_id, :mac_key, :mac_algorithm) end |