Class: Filch::Template
- Inherits:
-
Object
- Object
- Filch::Template
- Defined in:
- lib/filch.rb
Overview
The Template Object defines a template recieves a model Object, and a String representing the name of the template. returns a new object with the following attributes:
- associations_keys
-
an Array of Strings representing the names of the the Filch::Associations to be queryed.
- associations
-
a Hash of Strings representing the predicates to be queryed.
- attribute_keys
-
same as association_keys, for the the Filch::Attributes
- attributes
-
same as associations, for the Filch::Attributes.
- scope_keys
-
same as association_keys, for the Filch::Scopes
- scopes
-
same as associations, for the Filch::Scopes
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #associations ⇒ Object
- #associations_keys ⇒ Object
- #attributes ⇒ Object
- #attributes_keys ⇒ Object
- #default_values ⇒ Object
- #df_vals ⇒ Object
-
#initialize(model, template) ⇒ Template
constructor
A new instance of Template.
- #options ⇒ Object
- #scopes ⇒ Object
Constructor Details
#initialize(model, template) ⇒ Template
Returns a new instance of Template.
146 147 148 149 150 151 |
# File 'lib/filch.rb', line 146 def initialize(model, template) @model = model @template = template @assocs = Associations.new(model) @attrs = Attributes.new(model) end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
152 153 154 |
# File 'lib/filch.rb', line 152 def model @model end |
Instance Method Details
#associations ⇒ Object
162 163 164 |
# File 'lib/filch.rb', line 162 def associations @assocs.associations[@template] end |
#associations_keys ⇒ Object
166 167 168 |
# File 'lib/filch.rb', line 166 def associations_keys @assocs.associations_keys[@template] end |
#attributes ⇒ Object
154 155 156 |
# File 'lib/filch.rb', line 154 def attributes @attrs.attributes[@template] end |
#attributes_keys ⇒ Object
158 159 160 |
# File 'lib/filch.rb', line 158 def attributes_keys @attrs.attributes_keys[@template] end |
#default_values ⇒ Object
174 175 176 177 178 179 180 |
# File 'lib/filch.rb', line 174 def default_values if @model.methods.include?(:filch_defaults) df_vals.merge(@model.filch_defaults[@template]) else df_vals end end |
#df_vals ⇒ Object
170 171 172 |
# File 'lib/filch.rb', line 170 def df_vals {} end |
#options ⇒ Object
182 183 184 185 186 187 188 |
# File 'lib/filch.rb', line 182 def if @model.methods.include?(:filch_options) @model.[@template] || {} else {} end end |