This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Products | |
| class Update < Mutations::Command | |
| required do | |
| model :product | |
| integer :adjust_inventory | |
| end | |
| def validate | |
| if adjust_inventory == 0 | |
| return add_error(:adjust_inventory, :invalid, 'Inventory adjustment factory cannot be zero') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Product | |
| include Mongoid::Document | |
| include Mongoid::Timestamps | |
| include AASM | |
| field :name, type: String | |
| field :state, type: String | |
| field :price, type: Integer | |
| field :inventory, type: Integer, default: 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void SerialOsc::start(Listener *listener) | |
| { | |
| this->listener = listener; | |
| if (listener == nullptr || listenSocket != nullptr) { | |
| return; | |
| } | |
| for (int i = 0; i < portsToScan; i++) { | |
| int tempPort = listenPort + i; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MonomeDemo | |
| : public SerialOsc::Listener | |
| { | |
| public: | |
| MonomeDemo(SerialOsc *osc) | |
| : osc(osc) | |
| { | |
| osc->start(this); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int main(int argc, const char* argv[]) | |
| { | |
| std::string input; | |
| SerialOsc osc("test", 13000); | |
| MonomeDemo device(&osc); | |
| while (input != "q") { | |
| std::cout << "type 'q' to quit." << std::endl; | |
| std::getline(std::cin, input); | |
| } |
NewerOlder