Class: Yamori::Schema::Relations

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/yamori/schema.rb

Instance Method Summary collapse

Constructor Details

#initialize(relations) ⇒ Relations

Returns a new instance of Relations.



229
230
231
# File 'lib/yamori/schema.rb', line 229

def initialize(relations)
  @relations = relations.map{|r| Relation.new(name: r[:name], field: r[:field], class_name: r[:class_name])}
end

Instance Method Details

#each(&block) ⇒ Object



233
234
235
# File 'lib/yamori/schema.rb', line 233

def each(&block)
  relations.each(&block)
end

#find(name) ⇒ Object



241
242
243
# File 'lib/yamori/schema.rb', line 241

def find(name)
  relations.find{|r| r.name == name.to_sym}
end

#namesObject



237
238
239
# File 'lib/yamori/schema.rb', line 237

def names
  map(&:name).sort
end