Sha256: e52d369174d377407159b5ff8612356ae6b5aa25dee590b9e253aab2d376c85f
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
class ActiveSerializer::SerializationRulesValidator private :initialize def self.validate!(&rules) fake_objects = rules.arity.times.map do ActiveSerializer::Support::FakeObject.new end validator = self.new validator.instance_exec(*fake_objects, &rules) end def attribute(name, value = nil, &block) ActiveSerializer::Support::ArgsValidator.is_symbol!(name, 'attributes') end def attributes(*attrs) attrs.delete_at(-1) ActiveSerializer::Support::ArgsValidator.is_array_of_symbols!(attrs, 'attributes') end def namespace(name, &block) ActiveSerializer::Support::ArgsValidator.is_symbol!(name, 'namespace name') ActiveSerializer::Support::ArgsValidator.block_given!(block, 'namespace block') end def resource(name, object = nil, &block) ActiveSerializer::Support::ArgsValidator.is_symbol!(name, 'resource name') ActiveSerializer::Support::ArgsValidator.block_given!(block, 'resource block') end def resources(name, objects = nil, &block) ActiveSerializer::Support::ArgsValidator.is_symbol!(name, 'resources name') ActiveSerializer::Support::ArgsValidator.block_given!(block, 'resources block') end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_serializer-0.1.0 | lib/active_serializer/serialization_rules_validator.rb |