Class: Ricordami::HasAttributes::OptionsExpander
- Inherits:
-
Object
- Object
- Ricordami::HasAttributes::OptionsExpander
- Defined in:
- lib/ricordami/has_attributes.rb
Instance Method Summary collapse
-
#initialize(model, opts = {}) ⇒ OptionsExpander
constructor
A new instance of OptionsExpander.
- #sequence(model) ⇒ Object
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 |