diff options
| author | Marc Florisson | 2012-12-05 18:32:07 +0100 |
|---|---|---|
| committer | Marc Florisson | 2012-12-05 18:32:07 +0100 |
| commit | fdd87a8e14d3fcbf0f2fd91d6f2280e0128c73cf (patch) | |
| tree | 2dfc14269959e49f352fd84233ea88d635926ed8 /app/models/api | |
| parent | 2570573d472010249b753e404c6cad003a78ad39 (diff) | |
| download | chouette-core-fdd87a8e14d3fcbf0f2fd91d6f2280e0128c73cf.tar.bz2 | |
add more controllers in api/V1
Diffstat (limited to 'app/models/api')
| -rw-r--r-- | app/models/api/v1/api_key.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/app/models/api/v1/api_key.rb b/app/models/api/v1/api_key.rb new file mode 100644 index 000000000..af029e5f7 --- /dev/null +++ b/app/models/api/v1/api_key.rb @@ -0,0 +1,32 @@ +module Api + module V1 + class ApiKey + def initialize(token) + @organisation_id, @referential_id = token.split('-') + end + def self.create( organisation, referential) + ApiKey.new( "#{organisation.id}-#{referential.id}") + end + def token + "#{@organisation_id}-#{@referential_id}" + end + def exists? + organisation && referential + end + def referential_slug + referential.slug + end + def referential + @referential ||= organisation.referentials.find_by_id @referential_id + end + def eql?(other) + other.token == self.token + end + private + def organisation + @organisation ||= Organisation.find_by_id @organisation_id + end + end + end +end + |
