module Couchbase::Model::Attributes::ClassMethods

Public Instance Methods

attribute(*names) click to toggle source
# File lib/couchbase/model/attributes.rb, line 15
def attribute(*names)
  options = names.extract_options!

  names.each do |name|
    name = name.to_s
    attributes[name] = options[:default]

    define_attribute_methods([name])

    define_method(name) do
      read_attribute name
    end

    define_method("#{name}=") do |value|
      write_attribute name, value
    end
  end
end