Class: Subledger::Domain::Key
- Inherits:
-
Object
- Object
- Subledger::Domain::Key
- Includes:
- Subledger::Domain, Roles::Activatable, Roles::Archivable, Roles::Attributable, Roles::Collectable, Roles::Creatable, Roles::Identifiable, Roles::Readable, Roles::Restable, Roles::Storable
- Defined in:
- lib/subledger/domain/key.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Entity
Instance Attribute Summary collapse
-
#identity ⇒ Object
readonly
Returns the value of attribute identity.
-
#secret ⇒ Object
readonly
Returns the value of attribute secret.
Attributes included from Roles::Storable
Attributes included from Roles::Identifiable
Class Method Summary collapse
- .active_klass ⇒ Object
- .archived_klass ⇒ Object
- .post_keys ⇒ Object
- .root_klass ⇒ Object
- .sub_klasses ⇒ Object
Instance Method Summary collapse
- #authenticates?(this_secret) ⇒ Boolean
-
#initialize(args) ⇒ Key
constructor
A new instance of Key.
Methods included from Roles::Restable
#patch_hash, #post_hash, #serializable_hash, #to_json
Methods included from Roles::Archivable
Methods included from Roles::Activatable
Methods included from Roles::Collectable
Methods included from Roles::Readable
Methods included from Roles::Creatable
Methods included from Roles::Attributable
Methods included from Subledger::Domain
#==, #collection_name, #entity_name, included, #to_s
Constructor Details
#initialize(args) ⇒ Key
Returns a new instance of Key.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/subledger/domain/key.rb', line 44 def initialize args identifiable args storable args @identity = args[:identity] # TODO separate new and create if args[:bcrypt].nil? @secret = args[:secret] || UUID.as_string @bcrypt = BCrypt::Password.create( @secret, :cost => 5 ) elsif args[:bcrypt] @secret = args[:secret] @bcrypt = BCrypt::Password.new args[:bcrypt] end end |
Instance Attribute Details
#identity ⇒ Object (readonly)
Returns the value of attribute identity.
22 23 24 |
# File 'lib/subledger/domain/key.rb', line 22 def identity @identity end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
22 23 24 |
# File 'lib/subledger/domain/key.rb', line 22 def secret @secret end |
Class Method Details
.active_klass ⇒ Object
36 37 38 |
# File 'lib/subledger/domain/key.rb', line 36 def self.active_klass ActiveKey end |
.archived_klass ⇒ Object
40 41 42 |
# File 'lib/subledger/domain/key.rb', line 40 def self.archived_klass ArchivedKey end |
.post_keys ⇒ Object
24 25 26 |
# File 'lib/subledger/domain/key.rb', line 24 def self.post_keys [ :id, :identity ] end |
.root_klass ⇒ Object
28 29 30 |
# File 'lib/subledger/domain/key.rb', line 28 def self.root_klass Key end |
.sub_klasses ⇒ Object
32 33 34 |
# File 'lib/subledger/domain/key.rb', line 32 def self.sub_klasses [ archived_klass, active_klass ] end |
Instance Method Details
#authenticates?(this_secret) ⇒ Boolean
63 64 65 |
# File 'lib/subledger/domain/key.rb', line 63 def authenticates? this_secret bcrypt == this_secret end |