Sha256: 28fe2e7b70af5dd3eb33db81e4e2d263f0750e5489f26eafc7756837f53c92bf

Contents?: true

Size: 550 Bytes

Versions: 1

Compression:

Stored size: 550 Bytes

Contents

module Hari
  class Entity
    class Property
      module Builder

        def property(name, options = {})
          attr_accessor name
          validates_presence_of name if options[:required]

          self.properties << Property.new(name, options)
        end

        def properties(*args)
          options = args.extract_options!
          args.each { |name| property name, options }

          @properties ||= begin
            self == Hari::Entity ? [] : Hari::Entity.properties.dup
          end
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hari-0.0.1 lib/hari/entity/property/builder.rb