start on card editing
This commit is contained in:
16
app/models/merged/card.rb
Normal file
16
app/models/merged/card.rb
Normal file
@ -0,0 +1,16 @@
|
||||
module Merged
|
||||
class Card
|
||||
include ActiveModel::API
|
||||
include ActiveModel::Conversion
|
||||
extend ActiveModel::Naming
|
||||
|
||||
attr_reader :content , :section
|
||||
|
||||
def initialize(section , card_data)
|
||||
@section = section
|
||||
raise "No data #{card_data}" unless card_data.is_a?(Hash)
|
||||
@content = card_data
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -13,7 +13,7 @@ module Merged
|
||||
def initialize(page , index , section_data)
|
||||
@page = page
|
||||
raise "No number #{index}" unless index.is_a?(Integer)
|
||||
raise "No has #{section_data}" unless section_data.is_a?(Hash)
|
||||
raise "No hash #{section_data}" unless section_data.is_a?(Hash)
|
||||
@index = index
|
||||
@content = section_data
|
||||
end
|
||||
@ -28,6 +28,12 @@ module Merged
|
||||
@content[key] = value
|
||||
end
|
||||
|
||||
def cards
|
||||
element = @content["cards"]
|
||||
return [] if element.nil?
|
||||
element.collect{|card_content| Card.new(self , card_content)}
|
||||
end
|
||||
|
||||
def template
|
||||
@content["template"]
|
||||
end
|
||||
|
Reference in New Issue
Block a user