Class: Fob::Fob
- Inherits:
-
Object
- Object
- Fob::Fob
- Extended by:
- ActiveModel::Naming
- Includes:
- ActiveModel::Conversion, ActiveModel::Validations
- Defined in:
- lib/fob/fob.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args, &block) ⇒ Fob
constructor
A new instance of Fob.
- #persisted? ⇒ Boolean
- #save ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ Fob
Returns a new instance of Fob.
25 26 27 28 |
# File 'lib/fob/fob.rb', line 25 def initialize(*args, &block) super @persisted = false end |
Class Method Details
.has_one(name, options = {}) ⇒ Object
21 22 23 |
# File 'lib/fob/fob.rb', line 21 def self.has_one(name, ={}) include_model(name, ) end |
.represents(name, options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/fob/fob.rb', line 11 def self.represents(name, ={}) include_model(name, ) klass = name.to_s.camelcase singleton_class.instance_eval do define_method(:model_name) do ::ActiveModel::Name.new(self, nil, "#{klass}") end end end |
Instance Method Details
#persisted? ⇒ Boolean
34 35 36 |
# File 'lib/fob/fob.rb', line 34 def persisted? @persisted end |
#save ⇒ Object
30 31 32 |
# File 'lib/fob/fob.rb', line 30 def save @persisted = yield attributes end |