Class: Hiiro::PinRecord
- Inherits:
-
Object
- Object
- Hiiro::PinRecord
- Defined in:
- lib/hiiro/pin_record.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#value ⇒ Object
Value accessor — tries JSON parse, falls back to raw string.
- #value=(v) ⇒ Object
Class Method Details
.create_table!(db) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/hiiro/pin_record.rb', line 7 def self.create_table!(db) db.create_table?(:pins) do primary_key :id String :command, null: false String :key, null: false String :value_json unique [:command, :key] end end |
.find_key(cmd, key) ⇒ Object
29 |
# File 'lib/hiiro/pin_record.rb', line 29 def self.find_key(cmd, key) = where(command: cmd.to_s, key: key.to_s).first |
.for_command(cmd) ⇒ Object
28 |
# File 'lib/hiiro/pin_record.rb', line 28 def self.for_command(cmd) = where(command: cmd.to_s).all |