Module: CS::Relation::ClassMethod

Defined in:
lib/cs/relation.rb

Instance Method Summary collapse

Instance Method Details

#parameter(name, type, *args) ⇒ Object


171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/cs/relation.rb', line 171

def parameter(name, type, *args)
  attr_accessor name
  self.parameters ||= {}

  param = {type: type}
  param.merge!(args[0]) unless args.empty?

  self.class_eval %{
    def #{name}
      if @#{name}.nil? && (default = self.class.parameters[:#{name}][:default])
        @#{name} = default
      end

      @#{name}
    end
  }

  self.parameters[name] = param
end

#parameter_alias(name, name_alias) ⇒ Object


191
192
193
194
195
# File 'lib/cs/relation.rb', line 191

def parameter_alias(name, name_alias)
  attr_accessor name
  self.parameters_alias ||= {}
  self.parameters_alias[name] = name_alias
end

#parametersObject


209
210
211
# File 'lib/cs/relation.rb', line 209

def parameters
  @parameters
end

#parameters=(parameters) ⇒ Object


205
206
207
# File 'lib/cs/relation.rb', line 205

def parameters=(parameters)
  @parameters = parameters
end

#parameters_aliasObject


201
202
203
# File 'lib/cs/relation.rb', line 201

def parameters_alias
  @parameters_alias
end

#parameters_alias=(parameters_alias) ⇒ Object


197
198
199
# File 'lib/cs/relation.rb', line 197

def parameters_alias=(parameters_alias)
  @parameters_alias = parameters_alias
end