Module: ModelFact::ModelHelper
- Defined in:
- lib/model_fact/helpers/model_helper.rb
Defined Under Namespace
Modules: ClassMethods
Classes: ReqFieldNotAvail
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(mtd, *args, &block) ⇒ Object
73
74
75
|
# File 'lib/model_fact/helpers/model_helper.rb', line 73
def method_missing(mtd, *args, &block)
model.send(mtd, *args, &block)
end
|
Class Method Details
.included(klass) ⇒ Object
41
42
43
|
# File 'lib/model_fact/helpers/model_helper.rb', line 41
def self.included(klass)
klass.extend(ClassMethods)
end
|
Instance Method Details
#==(val) ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/model_fact/helpers/model_helper.rb', line 64
def ==(val)
if val.is_a?(ModelFact)
model == val.model
else
false
end
end
|
#_model_key ⇒ Object
55
56
57
|
# File 'lib/model_fact/helpers/model_helper.rb', line 55
def _model_key
self.class._model_key
end
|
#ensure_attributes_defined ⇒ Object
45
46
47
48
49
|
# File 'lib/model_fact/helpers/model_helper.rb', line 45
def ensure_attributes_defined
self.class.req_fields.each do |f|
raise ReqFieldNotAvail, "Requred field '#{f}' not available on #{self}" if not (self.respond_to?(f) and self.respond_to?("#{f}="))
end
end
|
#model ⇒ Object
59
60
61
|
# File 'lib/model_fact/helpers/model_helper.rb', line 59
def model
@_mdlInst
end
|
#set_model_instance(mdlInst) ⇒ Object
51
52
53
|
# File 'lib/model_fact/helpers/model_helper.rb', line 51
def set_model_instance(mdlInst)
@_mdlInst = mdlInst
end
|