Class: Toast::ConfigDSL::InCollection
- Inherits:
-
Object
- Object
- Toast::ConfigDSL::InCollection
- Includes:
- Blockenspiel::DSL
- Defined in:
- lib/toast/config_dsl.rb
Instance Method Summary collapse
- #exposed_associations ⇒ Object
- #exposed_attributes ⇒ Object
-
#initialize(model, base_config) ⇒ InCollection
constructor
A new instance of InCollection.
- #namespace(*arg) ⇒ Object
- #namespace=(arg) ⇒ Object
- #readables(*arg) ⇒ Object
- #readables=(readables) ⇒ Object
- #writables(*arg) ⇒ Object
- #writables=(arg) ⇒ Object
Constructor Details
#initialize(model, base_config) ⇒ InCollection
Returns a new instance of InCollection.
139 140 141 142 143 144 |
# File 'lib/toast/config_dsl.rb', line 139 def initialize model, base_config @model = model @media_type = "application/json" @readables = base_config.readables # must assign a reference @writables = base_config.writables # must assign a reference end |
Instance Method Details
#exposed_associations ⇒ Object
181 182 183 184 |
# File 'lib/toast/config_dsl.rb', line 181 def exposed_associations assocs = @model.reflect_on_all_associations.map{|a| a.name.to_s} (@readables + @writables).uniq.select{|f| assocs.include?(f)} end |
#exposed_attributes ⇒ Object
176 177 178 179 |
# File 'lib/toast/config_dsl.rb', line 176 def exposed_attributes assocs = @model.reflect_on_all_associations.map{|a| a.name.to_s} (@readables + @writables).uniq.select{|f| !assocs.include?(f)} end |
#namespace(*arg) ⇒ Object
166 167 168 |
# File 'lib/toast/config_dsl.rb', line 166 def namespace *arg self.writables = 42 end |
#namespace=(arg) ⇒ Object
170 171 172 173 174 |
# File 'lib/toast/config_dsl.rb', line 170 def namespace= arg puts puts "Toast Config Warning (#{model.class}): Defining \"namespace\" in collection definition has no effect." puts end |
#readables(*arg) ⇒ Object
151 152 153 154 |
# File 'lib/toast/config_dsl.rb', line 151 def readables *arg return(@readables) if arg.empty? self.readables = arg end |
#readables=(readables) ⇒ Object
146 147 148 149 |
# File 'lib/toast/config_dsl.rb', line 146 def readables= readables @writables = [] # forget inherited writables @readables = ConfigDSL.normalize(readables,"readables") end |
#writables(*arg) ⇒ Object
156 157 158 |
# File 'lib/toast/config_dsl.rb', line 156 def writables *arg self.writables = 42 end |
#writables=(arg) ⇒ Object
160 161 162 163 164 |
# File 'lib/toast/config_dsl.rb', line 160 def writables= arg puts puts "Toast Config Warning (#{model.class}): Defining \"writables\" in collection definition has no effect." puts end |