Class: Ricordami::HasAttributes::OptionsExpander

Inherits:
Object
  • Object
show all
Defined in:
lib/ricordami/has_attributes.rb

Instance Method Summary collapse

Constructor Details

#initialize(model, opts = {}) ⇒ OptionsExpander

Returns a new instance of OptionsExpander.



146
147
148
149
150
151
152
# File 'lib/ricordami/has_attributes.rb', line 146

def initialize(model, opts = {})
  opts.slice(:initial, :default).each do |name, value|
    next unless value.is_a?(Symbol) && respond_to?(value)
    opts[name] = send(value, model)
  end
  opts
end

Instance Method Details

#sequence(model) ⇒ Object



154
155
156
157
# File 'lib/ricordami/has_attributes.rb', line 154

def sequence(model)
  key = KeyNamer.sequence(model, :type => "id")
  Proc.new { model.redis.incr(key).to_s }
end