Class: Id::ActiveModel
- Inherits:
-
Object
show all
- Includes:
- ActiveModel::Conversion, ActiveModel::Validations
- Defined in:
- lib/id/active_model.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(model, data) ⇒ ActiveModel
Returns a new instance of ActiveModel.
9
10
11
12
|
# File 'lib/id/active_model.rb', line 9
def initialize(model, data)
@model = model
@data = data
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
24
25
26
27
|
# File 'lib/id/active_model.rb', line 24
def method_missing(name, *args, &block)
field = model.fields[name]
field.nil? ? model.send(name, *args, &block) : data[field.key]
end
|
Class Method Details
.i18n_scope ⇒ Object
5
6
7
|
# File 'lib/id/active_model.rb', line 5
def self.i18n_scope
:id
end
|
Instance Method Details
#respond_to?(name, include_private = false) ⇒ Boolean
18
19
20
|
# File 'lib/id/active_model.rb', line 18
def respond_to?(name, include_private = false)
super || model.respond_to?(name, include_private)
end
|
#to_partial_path ⇒ Object
14
15
16
|
# File 'lib/id/active_model.rb', line 14
def to_partial_path
model.respond_to?(:to_partial_path) ? model.to_partial_path : super
end
|