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
# app/validators/scss_format_validator.rb | |
class ScssFormatValidator < ActiveModel::EachValidator | |
def validate_each(object, attribute, value) | |
begin | |
# Attempt to parse SCSS | |
Sass::Engine.new(value, syntax: :scss).render | |
rescue Exception => e | |
# Add error if parsing fails | |
object.errors.add(attribute, :invalid_scss, error: e.inspect) | |
end |
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
require "aws-sdk" | |
class Dynamo | |
attr_accessor :attributes | |
def initialize(hash) | |
raise ArgumentError, "argument passed to .new must be a Hash" unless hash.is_a? Hash | |
raise ArgumentError, "hash must contain key :#{self.class.hash_key}" unless hash.has_key? self.class.hash_key.to_sym | |
raise ArgumentError, "hash must contain key :#{self.class.range_key}" unless self.class.has_range_key? && hash.has_key?(self.class.range_key.to_sym) | |
@attributes = {} |