Sha256: ae942678899f57f2586687ffcb6da07178f2c8691c4749f5e6dbe65bbcfaf9e7
Contents?: true
Size: 914 Bytes
Versions: 1
Compression:
Stored size: 914 Bytes
Contents
module RestfulObjects::ObjectMacros def property(name, type, options = {}) RestfulObjects::DomainModel.current.types[self.name].register_property(name.to_s, type, options) define_method(name) do instance_variable_get("@#{name}") end unless options[:read_only] define_method("#{name}=") do |value| if options[:max_length] && value && value.length > options[:max_length] raise ArgumentError.new("string max length exceeded") end instance_variable_set("@#{name}", value) end end end def collection(name, type, options = {}) type = type.name if type.is_a?(Class) RestfulObjects::DomainModel.current.types[self.name].register_collection(name.to_s, type, options) attr_reader(name) end def action(name, options = {}) RestfulObjects::DomainModel.current.types[self.name].register_action(name.to_s, options) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
restful_objects-0.0.8 | lib/restful_objects/domain_model/mixins/object_macros.rb |